With both
this recent topic and my own need for iterating over a bunch of values, I'd like to bring this request up again.
While the functionality can be emulated using variable variable names, doing so requires a bunch of actions, resulting in a difficult to read and maintain action list.
E.G. I used
Start Loop : Repeat From 0 to 2
Begin Integer Compare : [~i] Equals 0
Set Text [token] to 'PROCESSEXISTS'
Else If Integer Compare : [~i] Equals 1
Set Text [token] to 'WINDOWEXISTS'
Else If Integer Compare : [~i] Equals 2
Set Text [token] to 'PROCESSFOREGROUND'
End Condition
End Loop
where I could use
Set Text [list0] to 'PROCESSEXISTS'
Set Text [list1] to 'WINDOWEXISTS'
Set Text [list2] to 'PROCESSFOREGROUND'
Set integer [i] value to 0
Start Loop While : [{TXT:list{INT:i}}] Does Not Equal 'Not Set'
Set Text [token] to 'list{INT:i}'
Set integer [i] to [i] plus 1
End Loop
but would much prefer to use something like
Set List [myList] to 3 items
Start Loop : Each item in [myList] to 'token'
End Loop
and, in some situations, would love to use
Set List [myFirstList] to 3 items
Set List [mySecondList] to 3 items
Start Loop : Repeat From 0 to [{LISTCOUNT:myFirstList}]
Write [Blue] '{LIST:myFirstList:i} {LIST:mySecondList:i}' to log
End Loop
or, in others, like in the mentioned topic:
Begin List Search : [myList] has an item that Contains 'text'
End Condition
or
Begin List Search : [myList] has an item that Equals 'text'
End Condition
And all this is without getting into appending or inserting values in a variable sequence.
If I'm dreaming of this functionality anyway, these features, mainly modeled on System.Collections.Generic.List<string>, seem like they would be useful:
A "Set Item Values for a List" action, supporting:
Append literal item values (with token support), or another list (I.E. List<string>.Add)
Append items with their values derived from splitting a text value, with user-provided separator(s) (I.E. String.Split)
Clear variable value (I.E. List<string>.Clear)
Insert literal item values (with token support), or another list, at a given index (I.E. List<string>.Insert)
Remove item value by text (I.E. List<string>.Remove)
Remove all item values by text (I.E. List<string>.RemoveAll)
Remove item value by index (I.E. List<string>.RemoveAt)
Remove item values by index (from / to) (I.E. List<string>.RemoveRange) (to at least somewhat simplify the UI, this would be the only option supporting a range; If it is required to insert or append a range, an additional "Set Item Values for a List" action could be used first to remove the undesired items)
Alphabetize item values (I.E. List<string>.Sort())
A "Begin a Conditional (If Statement) Block" action "List" tab, supporting:
One or more item values Equal / Do Not Equal / Start With / Do Not Start With / Contain / Do Not Contain
Checked against a text token or literal value
Lists would have to allow null values (as strings are nullable), and checking the difference between null and and the literal text "Not Set" could be useful, so One or more item values Have Been Set / Have Not Been Set as well.
In addition,
List Equals / Does Not Equal another list
List Has been Set / Has Not Been Set
Individual item value checks could be done using the "{LIST:}" token in the "Text" tab, otherwise an optional index numericUpDown that only works for values and not whole lists is required.
A '{LISTPOS: textVariableName / text name : textVariableItemValue / text itemValue}' token (I.E. List<string>.IndexOf)
A '{LISTLASTPOS: textVariableName / text name : textVariableItemValue / text itemValue}' token (I.E. List<string>.FindLastIndex)
A '{LIST: textVariableName / text name : intVariableIndex / int index}' token, which allows retrieving a single item's value by its index (I.E. List<string>.Item[])
A '{LISTCOUNT: textVariableName / text name }' token that outputs the number of items in the list (I.E. List<string>.Count)
A '{LISTTXT: textVariableName / text name : textVariableSeparator / text separator }' token that outputs all items in the list with a chosen separator in between (E.G. '{LISTTXT:myList:", "}' to generate a csv, or '{LISTTXT:myList:";"}' for use with other VoiceAttack features)
On top of all that, as it would be a standard List<string>, using it in inline functions would be simple, and allow methods not exposed through the GUI/tokens like "Reverse" or "InsertRange".
This would also provide a way for inline function to store and pass data without having to encode and decode it to a delimited string (you'd still need to switch datatypes, but that's relatively painless if you're using simple datatypes, as the "ConvertAll" method does this for you).
Lastly, here's a slapped-together mockup of the "Set Item Values for a List" window:
That's 99% of the hard work done already, right?