bobh Posted May 26, 2010 Share Posted May 26, 2010 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 Link to comment Share on other sites More sharing options...
pete1234 Posted May 26, 2010 Share Posted May 26, 2010 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 Link to comment Share on other sites More sharing options...
KaFu Posted May 26, 2010 Share Posted May 26, 2010 Take a look at Assign() and it's examples in the help-file... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
bobh Posted May 26, 2010 Author Share Posted May 26, 2010 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 Link to comment Share on other sites More sharing options...
cageman Posted May 26, 2010 Share Posted May 26, 2010 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now