Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ForEach Tab delimited list array element loop
ForEach variable In list By delimiter
strList = "a,b,c,d,e,f" ; Convert list to an array arrA = ObjectType ("ARRAY", Arrayize (strList, ",")) intElements = ArrInfo (arrA, 1) If intElements intItem = 0 ; Access each element in the array ForEach arrElement In arrA intItem = intItem + 1 Message (intItem, arrElement) Next EndIf Exit... or the short version ...
; Short Version. ForEach strItem In ObjectType ("ARRAY", Arrayize ("a,b,c,d,e,f", ",")) Message ("",strItem) Next ExitHere is an example that uses a UDF to convert the list to an array object.
#DefineSubRoutine udsListToVTArray (strList, strDelimiter) Return ObjectType ("ARRAY", Arrayize (strList, strDelimiter)) #EndSubRoutine strListColors = "red,green,blue" arrColors = udsListToVTArray (strListColors, ",") ForEach strColor In arrColors Pause ("Color Collection", strColor) Next Exit
Article ID: W17662
Filename: ForEach in Array Trick.txt
File Created: 2012:02:27:09:41:44
Last Updated: 2012:02:27:09:41:44