Assignment Operations and Arrays
The following table shows the variations possible in expressions containing array and scalar subscripts. The result of the assignment operation depends upon the dimensionality of the subscript.
Note
A subscript structure can also be composed of a range of elements. If expression is scalar, it is inserted into the subarray. If Variable[Range] and Array are the same size, elements of Array specified by Range are inserted in Variable. It is illegal if Variable[Range] and Array are different sizes. See Subscript Ranges for complete details. For information on when you should not use subscript ranges, see Avoid Using Range Subscripts.
|
Syntax Structure
|
Description
|
|---|---|
| Expression is stored in a single element of Variable. |
|
| Expression array is inserted in Variable array beginning at point indicated by subscript.
Note - An "out of range subscript" error will occur if you attempt to insert |
|
| Expression scalar is stored in designated elements of Variable. Other array elements are unchanged.
Note - Note the use of the double brackets. Attempting to assign zeros to the 3rd and 5th element of the array using |
|
| Elements of Expression are stored in designated elements of Variable.
Note - Elements of the subscript array that are negative, or greater than the highest subscript of the subscripted array, are clipped to the target array boundaries. For example, |
Note
Array operations are much more efficient than loops. See Use Vector and Array Operations for details.