Sign in to follow this  
Followers 0
bobh

Dynamic Variables

5 posts in this topic

1st time appender!

I've used Autoit numerous times and it's a good language. I have a situation where I want to dynamically create a variable with a name equal to the value of some other fixed name variable. For example if $var1 = "bob", then I want to create a variable named "bob". Since the fixed variable can have any value, the newly created variable name is dynamic. I've done this in a few other langauges especially when I'm processing large ini files. I read a key/value set from an INI and then create a variable with the key "name" equal to the key "value".

Can anything like this be done in Autoit??

Thanks

BobH

Share this post


Link to post
Share on other sites



Have you looked at IniReadSection? It will store the results in an array which you can refer to without having to create variables for every key

Share this post


Link to post
Share on other sites

On the surface, it looks like "Assign" will do what I'm looking for. I scanned the help numerous time and missed it. Thanks.

I'm not using inireadsection because it would create the array elements in the order they exist in the ini file. In my case I cannot assume the keys are always in the same order. Creating variables from the keys means I can just check the value of the variable regardless of the its order in the section.

Thanks again for the quick responses

BobH

Share this post


Link to post
Share on other sites

You could also create an array in this case first column key name second column key value.

and search the array every time you want a value, you could make a function for it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0