MAT COPY


General Form:

MAT COPY [-] alpha_variable1 [<start,count>] TO alpha_variable2 [<start,count>]
Where:
start, count = a numeric expression

The MAT COPY statement is used to copy the contents of the source alpha variable or array into another alpha variable or array.

The copy is performed on a byte-by-byte basis, until the receiver variable is filled. If the receiver variable is larger than the source variable, MAT COPY will fill the remaining bytes with spaces.

Portions of data can be copied to or from the variables or arrays using either the FLD( or STR( functions. An obsolete and deprecated syntax using <> also allows the start and count parameters used by the STR( function to be specified separately. For example the following two statements both perform the same task:

MAT COPY STR(temp$(),5,5) TO STR(file$(),7,5)
MAT COPY temp$() <5,5> TO file$() <7,5>

By default MAT COPY copies the data in the order specified by the source variable and left justifies the data in the output variable. A minus sign can precede either the source variable or the receiving variable or both.

The following example shows the various versions of the MAT COPY statement with the contents of the receiver variable when given the two lines of code shown below.

DIM abc$(4)2, xyz$(5)2
abc$() = "A B C D "

MAT COPY abc$() TO xyz$() xyz$() = "A B C D   "
MAT COPY -abc$() TO xyz$() xyz$() = " D C B A  "
MAT COPY abc$() TO -xyz$() xyz$() = "   D C B A"
MAT COPY -abc$() TO -xyz$() xyz$() = "  A B C D "