AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

associative arrays

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
tinku99



Joined: 03 Aug 2007
Posts: 513
Location: Houston, TX

PostPosted: Mon May 25, 2009 2:44 pm    Post subject: associative arrays Reply with quote

functions as objects using assume static:
just change "object" function name to whatever name you want your object to have. You can use addFile() from autohotkey.dll to create as many of these as you want dynamically. Avoid using these in long loops as function calls are inefficient.
Code:
object(member, value = 0, null = 0)
{
static
if value
_%member% := value
else if null
_%member% := ""
return (_%member%)
}
test script:
Code:
F1::
inputbox, var, var
inputbox, val, val
msgbox % object(var, val)
return

F2::
inputbox, var, var
msgbox % object(var)
return
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rabiator



Joined: 17 Apr 2005
Posts: 289
Location: Sauerland

PostPosted: Mon May 25, 2009 7:41 pm    Post subject: Re: associative arrays Reply with quote

That's a fine idea, thank you!

However, it is not possible to assign the value 0 to the member. Has the "else" to be removed?
Back to top
View user's profile Send private message
tinku99



Joined: 03 Aug 2007
Posts: 513
Location: Houston, TX

PostPosted: Tue May 26, 2009 4:51 am    Post subject: assigning 0 Reply with quote

try this:
object(member, value = 0, null = 0)
{
static
if value
_%member% := value
else if null
_%member% := 0
return (_%member%)
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group