The meaning of source and target varies according to the options for the statement. See the sections below for the different forms of the move statement.
justify is available for fixed length text type target variables, or fixed length text type arrays only. The justification operation occurs on the target after the source has been moved by the standard EGL operation, including any data type conversion. If a sub-string is specified on the target variable, then the justification modifies only the sub-stringed characters.
move {justify=left} a to b;
If left is specified, any leading blanks in the resulting target operand are removed and the value is shifted left. The source operand is not altered. Any needed characters on the right side of a fixed length target variable are inserted as spaces.
move {justify=right} a to b;
If right is specified, any trailing blanks in the resulting target operand are removed and the value is shifted right. The source operand is not altered. Any needed characters on the left side of a fixed length target variable are inserted as spaces.
If you do not specify a byName or byPosition qualifier for the move statement, EGL moves the information byte-by-byte from the source to the target. The source must be assignment compatible with the target; for details, see “Assignment compatibility in EGL.”
In this form of the move statement, EGL assigns data from each field in the source to a field of the same name in the target. The operation occurs in the order in which the fields are in the source. The source must be assignment compatible with the target; for details, see “Assignment compatibility in EGL.”
A structure field whose name is an asterisk (*) is not available as a source field, but any named field in a substructure of that field is available.
10 empnum CHAR(3);
10 empname CHAR(20);
10 empnum CHAR(3)[10];
10 empname CHAR(20)[10];
10 mySubStructure[10]
15 empnum CHAR(3);
15 empname CHAR(20);
10 empnum CHAR(3);
10 empname CHAR(20)[10];
10 empnum CHAR(3)[10];
10 empname CHAR(20);
EGL copies the value of the empnum field from the source to the first element of empnum in the target, and copies the value of the first element of empname from the source to the field empname in the target. The move statement finishes here because no further copying can take place without changing the target empname to an array.
In this form of the move statement, EGL copies data from each field in the source to a field in the equivalent position in the target. EGL copies each field byte by byte, in order of its position in the source. The source must be assignment compatible with the target; for details, see “Assignment compatibility in EGL.”
When you move data between a record and a structured record or field, only the top-level fields of the target are considered. When you move data between two structured records or fields, only the lowest-level (leaf) fields of either are considered.
The operation is not valid if the source or target field is a multidimensional structure field array, or a one-dimensional structure field array within an array.
record myCustomer type BasicRecord
customerNumber CHAR(6);
customerName CHAR(25);
end
record mySavedCustomer type BasicRecord
savedCustomerNumber CHAR(6);
savedCustomerName CHAR(25);
end
...
move myCustomer to mySavedCustomer byPosition;
When the target of the move statement is an array, you can assign values to all elements (for all) or a sequential subset of elements (for count).
The move statement with arrays is equivalent to multiple EGL byte by byte copies, one per target array element, and an error occurs if an attempted copy is not valid. For details on validity, see Assignments.
When for all or for count is in use, the move statement ignores substructure.
If the source is an array or an element of an array, each successive element of the source array is copied to the next sequential element of the target array. Either the target array or the source array can be longer, and the operation ends when data is copied from the last element having a matching element in the other array.
If the source is an element of an array, the source is treated as an array in which the specified element is the first element, and previous elements are ignored.
If the source is neither an array nor an element of an array, the operation uses the source value to initialize every element of the target array.
If the source is a record array (or an element of one), the target must be a record array. If the source is a primitive-variable array (or an element of one), the target must be either a primitive-variable array or a structure-field array. If the source is a structure-field array (or an element of one), the target must be either a primitive-variable array or a structure-field array.
move "abc" to target[7] for 3;
move source[2] to target[7] for 3;
The withV60Compat modifier is used in programs migrated from EGL version 6 and earlier, or from VisualAge® Generator programs. Do not use this modifier with new code.
Use this modifier when the variables that the move statement references are declared in a standalone function, where migration cannot determine the type of the variable. This option provides compatibility for a move statement without a modifier.
Platform | Issue |
---|---|
Rich UI | move is not supported except byName for flexible record. |