| View previous topic :: View next topic |
| Author |
Message |
tinku99
Joined: 03 Aug 2007 Posts: 513 Location: Houston, TX
|
Posted: Mon May 25, 2009 2:44 pm Post subject: associative arrays |
|
|
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 |
|
 |
Rabiator
Joined: 17 Apr 2005 Posts: 289 Location: Sauerland
|
Posted: Mon May 25, 2009 7:41 pm Post subject: Re: associative arrays |
|
|
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 |
|
 |
tinku99
Joined: 03 Aug 2007 Posts: 513 Location: Houston, TX
|
Posted: Tue May 26, 2009 4:51 am Post subject: assigning 0 |
|
|
try this:
object(member, value = 0, null = 0)
{
static
if value
_%member% := value
else if null
_%member% := 0
return (_%member%)
} |
|
| Back to top |
|
 |
|