Skip to main content
Previous section   Next section

MAT

Assigns values to all the elements in a dimensioned array.

Synopsis

MAT array = value

MAT array1 = MAT array2

Arguments

array Name of an existing array. This array must have been dimensioned using the DIM statement.
value The value to assign to all of the elements of the array. An expression that resolves to a value.

Description

The MAT statement assigns values to all of the elements of a specified array. This array may be one-dimensional or two-dimensional. MAT has two forms:

  • MAT array=value assigns the same value to every element of the array.

  • MAT array1=MAT array2 assigns the values of the elements in array2 to the corresponding elements in array1. Both array1 and array2 must already have been dimensioned using the DIM statement. The arrays may be differently dimensioned. If there are more elements in array2 than array1, the excess array2 elements are ignored. If there are more elements in array1 than array2, the excess array1 elements are not assigned a value. All uninitialized variables are treated as zero-length strings ("").

Note:

This statement cannot be executed from the MVBasic command shell. Attempting to do so results in a MVBasic syntax error.

Emulation

D3 supports array1 = MAT array2 as functionally equivalent to MAT array1 = MAT array2.

Examples

The following examples illustrate the use of the MAT statement:

! Dimension a one-dimensional array with 6 elements.
DIM MyVector1(6)
! Dimension a one-dimensional array with 10 elements.
DIM MyVector2(10)
! Assign the value "pending" to all elements of MyVector2
MAT MyVector2="pending"
! Assign the values of elements of one array to another array
MAT MyVector1=MAT MyVector2
! Results are a that MyVector1 contains 6 elements all assigned
! the value "pending"
Copy code to clipboard

See Also