Hilmas User's Guide | ||
---|---|---|
Back | Language Basics | Next |
The main statement to initialize and move data between variables is MOVE. MOVE syntax is:
MOVE input-value,TO,output-var
where input-value can be a constant or a variable of any type and output-var must be a variable of the same type of the input-value.
If the input-value is a string (or a global variable) bigger than output-var, input-value is truncated; if output-var is bigger then input-value (and the string is smaller then 256) output-var is padded with spaces.
MOVE is also the unique Hilmas statement that can manage strings with size greater then 255 bytesSee MOVE page in Language reference for more details.
We have seen in the previous page how arrays must be defined.
None of the Hilmas statements can directly process an array element. The only statement that can get or put an array element is MOVARRAY statement. In fact, MOVARRAY meaning is MOVe element to/from an ARRAY.
So, to process an array element, you must first move them into a scalar variable (a single variable) of the same type and length using MOVARRAY TO statement, process it with the Hilmas statements you want, and then put it in the previous location inside the array using MOVARRAY FROM statement (if this move is needed).
MOVARRAY statement uses an index (or more indexes if array has 2 or 3 dimensions) to search the wanted element inside the storage defined for the array; than moves this element into the single variable if statement has INTO keyword, or moves from the single variable inside the array if the statement has FROM keyword.
MOVARRAY syntax is:
MOVARRAY array,(x[,y[,z]]),TO,var[,D1=d1[,D2=d2]][,SLEN=l-str]or
MOVARRAY array,(x[,y[,z]]),FROM,var[,D1=d1[,D2=d2]][,SLEN=l-str]As an example, if we have an array of 10 positive integers and we must search the maximum value:
MOVE 0,TO,MAX
FOR I,0,9
MOVARRAY IARRAY,(I),TO,VAL
IF (VAL,>,MAX) THEN
MOVE VAL,TO,MAX
ENDIF
NEXT
. . . . .
MAX DS F
VAL DS F
I DS F
IARRAY 10FTo initialize an array you must use a similar loop with a MOVARRAY FROM; to manage a two dimension array, you will use MOVARRAY statement(s) inside a double loop that scans the two dimensions with two indexes I and J; and so on.
Indexes must be integers (type F or H); remember that the first element of an array has index equal to 0.
var is the single variable and must have the same type of array; D1 ad D2 are the first or second dimension of the array and must be specifyed when dimensions are, respectively, 2 or 3.
SLEN is mandatory when array contains strings and specifys the length of every element.
See MOVARRAY page in Language reference for more details.
Back | Start | Next |
Variables | Top | Expressions |