VisualNEO for Windows also allows the use of compound variable names to produce something called an array. An array is a collection of related variables. Each variable in the array is referred to by the name of the array followed by its position within the array. For example, a ten item array called Name would contain variables [Name1], [Name2], [Name3], [Name4], and so on, up to [Name10].


Arrays can be defined explicitly like [Name1] or by using compound variables like [Name[X]], where [X] is an incremented numeric value. Such an array could be used to store lines read from a file like this:


FileLen "sample.txt" "[FLen]"

Loop "1" "[FLen]" "[X]"

  FileRead "sample.txt" "[X]" "[Name[X]]"

EndLoop


After executing these Actions, the number of items in the array should be equal the number of lines in the file ([FLen]). (The FileLen Action counts the number of lines in the file and stores that number in the variable [FLen]. More information about these Actions can be found here.) Individual items in the array could be accessed directly like this:


AlertBox "Results" "Line 5 = [Name5]"


or the entire array can be processed like this:


Loop "1" "[FLen]" "[X]"

  AlertBox "Results" "Line [X] = [Name[X]]"

EndLoop


Like individual variables, it’s not necessary to delete arrays. If needed, however, you can delete array elements individually using SetVar. You can remove an entire array using the DeleteArray Action. For example:


DeleteArray "[Name]" "[FLen]"


If you don’t know the bounds or size of an array, you can use the GetArrayInfo Action to find out:


GetArrayInfo "[Name]" "[FirstItem]" "[LastItem]" "[ArraySize]"