MAT statement

Syntax

MAT array = expression
MAT array1 = MAT array2

Description

Use the MAT statement to assign one value to all of the elements in the array or to assign all the values of one array to the values of another array.

Use the first syntax to assign the same value to all array elements. Use any valid expression. The value of expression becomes the value of each array element.

Use the second syntax to assign values from the elements of array2 to the elements of array1. Both arrays must previously be named and dimensioned. The dimensioning of the two arrays can be different. The values of the elements of the new array are assigned in consecutive order, regardless of whether the dimensions of the arrays are the same or not. If array2 has more elements than in array1, the extra elements are ignored. If array2 has fewer elements, the extra elements of array1 are not assigned.

Note: Do not use the MAT statement to assign individual elements of an array.

Examples

Source Lines
Program Output
DIM ARRAY(5) QTY=10 MAT ARRAY=QTY FOR X=1 TO 5 PRINT "ARRAY(":X:")=",ARRAY(X) NEXT X
ARRAY(1)=     10
ARRAY(2)=     10
ARRAY(3)=     10
ARRAY(4)=     10
ARRAY(5)=     10
DIM ONE(4,1) MAT ONE=1 DIM TWO(2,2) MAT TWO = MAT ONE FOR Y=1 TO 4 PRINT "ONE(":Y:",1)=",ONE(Y,1) NEXT Y
ONE(1,1)=     1
ONE(2,1)=     1
ONE(3,1)=     1
ONE(4,1)=     1
DIM ONE(4,1) MAT ONE=1 DIM TWO(2,2) MAT TWO = MAT ONE FOR X=1 TO 2 FOR Y=1 TO 2 PRINT "TWO(":X:",":Y:")=",TWO(X,Y) NEXT Y NEXT X
TWO(1,1)=     1
TWO(1,2)=     1
TWO(2,1)=     1
TWO(2,2)=     1

The following example sets all elements in ARRAY to the empty string:

MAT ARRAY=''