lexikos wrote: ↑21 Aug 2022, 16:57
I have yet to see a compelling example demonstrating the value of dynamically creating variables.
Well, for me it is a quick way to emulate enums...
Code: Select all
; instead of this:
Director := 1
Officer := 2
Owner := 3
Subordinate := 4
; i do a two liner:
for title in ["Director", "Officer", "Owner", "Subordinate"]
%title% := a_index
And is flexible enough if I need to add a variable between officer and owner and dont want to modify the other 20 variables i had already written
In other situations I am getting data from external sources (i do webscraping very often) and find myself trying to organize the data in a meaningful way based on the info I received, and resort to looping and creating certain types of variables on the fly.
of course, my situations are basically edge cases, and Im fine with autohotkey not handling those things optimally but i just found it suprising that i couldnt do it in v2
lexikos wrote: ↑21 Aug 2022, 16:57
More examples.
Code: Select all
for title in [&Director, &Owner, &Officer]
%title% := a_index
Msgbox officer
I think this is just perfect or what I need, Never thought that just "mentioning" the variable as a varRef would do the trick.