AutoHotKey: How to access array with counter variable -


; declare window_title_array window_title_array%1% = 3270 display - window_title_array%2% = 3270 display - b window_title_array%3% = 3270 display - c window_title_array%4% = 3270 display - d window_title_array%5% = 3270 display - e window_title_array%6% = 3270 display - f  counter := 1  my_string := window_title_array%counter%  msgbox, %my_string% 

how string array counter variable? tried counter = 1 , counter := 1. both of them failed access array. not sure mistake. thank you!

ps: version have quite outdated - version 1.0.47.06

i believe it's in how you're creating array. putting percent signs around array indexes, you're saying want use first file-level input parameter (in case of using %1%). blank, ends looking variable named "window_title_array"

take out percents. should use this:

window_title_array1 = 3270 display - window_title_array2 = 3270 display - b window_title_array3 = 3270 display - c window_title_array4 = 3270 display - d window_title_array5 = 3270 display - e window_title_array6 = 3270 display - f 

and not this:

window_title_array%1% = 3270 display - window_title_array%2% = 3270 display - b window_title_array%3% = 3270 display - c window_title_array%4% = 3270 display - d window_title_array%5% = 3270 display - e window_title_array%6% = 3270 display - f 

and if want reference counter variable, ... (looking @ code)... are.

and note not native array in ahk. if have older version may not able use native arrays. how arrays done long time in ahk.

furthermore, way deal creating "built-in" counter/length variable , use dynamically number arrays. can referenced in array loops etc. , notice no hand-coding of array indexes, means can add more or insert them without having renumber anything. i'm doing arrays of structures, , below simple example...

myarr0 = 0  ; @ end, hold count of array  myarr0++ myarr%myarr0%_firstname = john myarr%myarr0%_lastname = smith  myarr0++ myarr%myarr0%_firstname = bill myarr%myarr0%_lastname = jones  mynames =  ; assemble list of names, simple example loop, %myarr0% { mynames := mynames . myarr%a_index%_firstname . ", " } 

and use <array name>0 syntax counter because that's same syntax outputted stringsplit command.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -