EGL Reference Guide for iSeries

move

The EGL move statement copies data, in most cases from the named items in one structure to the same-named items in another.



Syntax diagram for the move statement

source
One of these:

The effect of the move statement varies by the source type:

target
One of these:
byName
When you specify byName and the target is not an array of records, the value of each subordinate item in the source structure is copied to the corresponding item with the same name in the target structure. The operation occurs in the order in which the items appear in the source structure. The operation is not valid if two or more items in the source or target structure have the same name.

Items whose name is an asterisk (*) are not themselves available, but their substructured, named items are available.

When you specify byName and the target is an array of records, the named areas in the source are copied to the same-named areas in successive elements of the target array. The operation is equivalent to a series of move statements, each of which assigns values to another array element.

for all
Meaningful only when the target is an array; otherwise, for all is ignored.

If the source is an element of an array, the operation moves that element and each subsequent element of the source array to an element in the target array.

Either the source or target array can be longer, and the process ends after data is copied between the last elements for which a match is found.

If the source is not an array, the operation uses the source value to initialize every element in the target array.

Depending on the source type, the operation is equivalent to a series of move statements or a series of assignment statements, as described earlier for source.

for count
Meaningful only when the target is an array; otherwise, for count is ignored.

count can be any of these:

If the source is an element of an array, the operation moves that element and each subsequent element of the source array to the corresponding target-array element, but only for the number of elements specified in count. The subscripts on the source and target arrays are the starting points for the move. For example, you can specify the following statement:

  move source[2] to target[7] for 3;

The previous example moves elements 2, 3, and 4 from source into the elements 7, 8, and 9 in target.

Either the source or target array can be longer, and the process ends after the first of two events occurs:

If the source is not an element of an array, the operation uses the source value to initialize the elements of the target array, beginning with the subscript specified on the target array and continuing for the number of elements specified in count. If the number of elements in the target array exceeds the number in count, the operation initializes all the elements in the target array.

Depending on the source type, the operation is equivalent to a series of move statements or a series of assignment statements, as described earlier for source.

An example is as follows:

  move myRecord01 to myRecord02 byName;

Moves are checked for item-to-item compatibility. The rules for truncation, padding, and type conversion are the same as those detailed for the assignment statement.

When you are working with dynamic arrays, the last element in the array is determined by the array's current size. For details, see Arrays.


Related reference
Arrays
Assignments


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]