Arrays
You can use arrays to form a matrix of values. The matrix can be multidimensional and can contain Data Structures, Enumerated Data Types, New Data Types, values from other Arrays and any of the built-in value types such as INT, REAL, and STRING.
NOTE: Arrays can only be used with internal variables. For direct variables, you have to use the VECTOR keyword, see Vectors.
To create an array, define the Array within the VAR and END_VAR keywords using the following format:
<Array Name> : ARRAY [<x dimensions>, <y dimensions>] OF <Value Type or Value Name>;
For example:
VAR
TEMPERATURE_MATRIX:ARRAY[1..4,1..5] OF REAL;
END_VAR
In this example, the name of the array is TEMPERATURE_MATRIX. [1..4,1..5] defines the columns and rows of the matrix (1x4 columns, 1x5 rows) and OF REAL; defines the type of values that are to be entered in the matrix.
When it comes to defining values for each of the matrix cells, you need to define the value in the following format:
<Value name>[<matrix grid reference>]:=<value>;
For example:
EngineTemperature[2,5]:=42.5;
This would place the value 42.5 in the second column in cell 5, like this:
42.5 |
In ViewX, you can use the Debug tool to view the values for each cell (see Debugging an ST Program).
Further Information