-
Notifications
You must be signed in to change notification settings - Fork 8
readToArray
MicroBlaster edited this page Nov 11, 2019
·
2 revisions
Purpose: Reads a text file directly into a TWX array.
Syntax: readToArray {file} storageArray
{file}: The file to read text from.
storageArray: The TWX Array to store the strings in.
Notes: This command is especially useful when reading in large text files, especially those greater than 10K lines. The array will be created and populated in one step. Any existing array with the same name will first be overwritten. Also, a variable with the same name as the array will be created, and its integer value will be the the element count of the array.
Example:
# Read a text file into an array
readToArray figlist.txt $figArray
# A variable $figArray also exists, and is equal to the element count
echo "*Figged Sectors read:" $figArray
setVar $i 1
while ($i <= $figArray)
echo "*" $figArray[$i]
add $i 1
end
.