ReadXY

(Engine-Level Function)

Description: Reads data points from a file into the elements of two arrays.
Returns: Array
Usage: Script Only.
Function Groups: Array,  File I/O
Related to: FRead | ReadX | SRead
Format: ReadXY(XArrayElem, YArrayElem, N, File)
Parameters:  
XArrayElem
Required. Any array element giving the starting point in the array in which to store the X coordinates. 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.
YArrayElem
Required. Any array element giving the starting point in the array in which to store the Y coordinates. 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 elements given by the first two parameters.
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 data are then alternately placed into each of the two arrays. 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 that array will be set to invalid. If the file contains fewer than N values, the remaining values will also be invalid.

The arrays need not start at the same index number.
This statement is useful for importing (X, Y) data from other databases or spreadsheets into VTScada.

Example:

If MatchKeys(1, "R");
[
  ReadXY(chlorineCon[0] { Starting point in first array },
         pumpSpeed[0] { Starting point in second array },
         60 { Number of elements to read },
         "CHLORINE.TXT" { File from which to read data });
]

This reads 60 numbers from the text file called CHLORINE.TXT into elements 0 to 29 of chlorineCon and pumpSpeed when a capital R is pressed at the keyboard. Numbers are placed in alternating arrays as they are read.