ReadX

(Engine-Level Function)

Description Reads numeric data from a text file into the elements of an array.
Returns Array
Usage Script Only.
Function Groups Array,  File I/O
Related to: FRead | SRead | ReadXY
Format: ReadX(ArrayElem, N, File)
Parameters  
ArrayElem
Required. Any array element giving the starting point in the array in which to store the data. The subscript for the array may be any numeric expression.

If processing a multidimensional array, the usual rules apply to decide which dimension should be used. The array may be either statically declared or dynamically allocated.
N
Required. Any numeric expression giving the number of array elements to read starting at the element given by the first parameter.

If N extends past the upper bound of the lowest array dimension, this computation will "wrap-around" and resume at element 0, until N elements have been processed.
File
Required. A text expression giving the file name of the data file. It should be enclosed in double quotes if it is a constant. A known path Known Path Aliases for File-Related Functions for File-Related Functions may be provided in the form, :{KnownPathAlias}.
Comments The data should be stored in the file with one numeric value per line. The EOF marker for the file must not be on the same line as the last numeric value, as per the following rule

If more than one value exists on a line, if the line is left blank, or if it contains a non-numeric character, the corresponding element in the array will be set to invalid.
If the file contains fewer than N values, the remaining values will also be invalid.
This statement is useful for importing data from other databases into VTScada.

Example:

If MatchKeys(1, "G");
[
  ReadX(chlorineCon[0] { Starting point in array },
        30 { Number of elements to read },
        "CHLORINE.TXT" { File from which to read data });
]

This reads 30 numbers from the text file called CHLORINE.TXT into elements 0 to 29 of chlorineCon when a capital G is pressed on the keyboard.