


The MOVE statement transfers data to data items.
General Format
Format 1
MOVE source-item TO {dest-item} ...
Format 2
MOVE {CORRESPONDING} source-group TO dest-group
{CORR }
Format 3
MOVE alpha-item TO dest-item WITH {CONVERSION}
{CONVERT }
[ ON EXCEPTION statement-1 ]
[ NOT ON EXCEPTION statement-2 ]
[ END-MOVE ]
Syntax Rules
1. Source-item is a literal or data item that represents the sending area.
2. Dest-item is a data item that receives the data.
3. Source-group and dest-group must be group items.
4. Alpha-item is a literal or data item of class alphanumeric.
5. CORR is an abbreviation for CORRESPONDING.
6. If dest-item is numeric or numeric edited, source-item may not be HIGH-VALUES, LOW-VALUES, SPACES, or QUOTES.
7. Source-item and dest-item must be of a compatible category. See General Rule 9 below.
8. Statement-1 and statement-2 are imperative statements.
General Rules
1. A Format 1 MOVE statement moves source-item to each dest-item in the same order in which they appear in the statement.
2. Subscript evaluation for source-item occurs once before the move to the first dest-item.
3. Subscript evaluation for dest-item occurs immediately before the move to that item.
4. The length of source-item is computed once immediately before the move to the first dest-item. The compiler option "-Dz" modifies size checking rules for numeric moves.
5. The length of dest-item is computed immediately before the MOVE to that item.
6. When the CORRESPONDING phrase is used, selected elementary items in source-group are moved to corresponding items in dest-group. This is treated as a series of Format 1 MOVE statements, one for each corresponding pair of data items.
7. The effects and legality of a MOVE statement depend on the category of the source-item and dest-item. Data items are assigned a category according to their PICTURE clause. Literals are assigned a category based on the following rules:
a) Numeric literals are numeric. Nonnumeric literals are alphanumeric.
b) The figurative constant ZERO is numeric when dest-item is numeric or numeric edited, otherwise it is alphanumeric.
c) The figurative constant SPACE is alphabetic.
d) All other figurative constants are alphanumeric.
8. Any Format 1 MOVE statement that has a group item as either a source or destination item is treated as a simple alphanumeric to alphanumeric move. (No implied conversion is implied.) Any category of data may be the source or destination of a group item MOVE.
9. The following table outlines the combinations of source-item and dest-item that are allowed by the MOVE statement. The numbers in the table are the "General Rules" numbers in this section where each combination is described:
|
| Receiving Item Category
|
|
|
| Alphanumeric Edited
| Numeric
|
| Sending Category
| Alphabetic
| Alphanumeric
| Numeric Edited
|
| Alphabetic
| Yes (10)
| Yes (11)
| No (13)
|
| Alphanumeric
| Yes (10)
| Yes (11)
| Yes (12)
|
| Alphanumeric Edited
| Yes (10)
| Yes (11)
| No (13)
|
| Numeric Integer
| No (13)
| Yes (11)
| Yes (12)
|
| Numeric Non-integer
| No (13)
| No (13)
| Yes (12)
|
| Numeric Edited
| No (13)
| Yes (11)
| Yes (12) |
11. When dest-item is alphanumeric or alphanumeric edited, justification and space filling occur according to the standard alignment rules. If source-item is signed numeric, the operational sign is not moved. If the sign occupies a separate character position, that sign character is not moved, and the size of source-item is treated as being one less.
12. When dest-item is numeric or numeric edited, decimal point alignment and zero filling occur according to the standard alignment rules. If source-item is unsigned, it is treated as being positive. If dest-item is unsigned, the absolute value of source-item is moved. If dest-item is signed, its sign is set to the sign of source-item. If source-item is numeric edited, it is "de-edited" first such that dest-item receives the same numeric value.
13. The following moves are illegal:
a) An alphabetic or alphanumeric edited data item may not be moved to a numeric or numeric edited data item.
b) A numeric or numeric edited data item may not be moved to an alphabetic item.
c) A non-integer numeric data item cannot be moved to an alphanumeric or alphanumeric edited data item.
14. A Format 3 MOVE statement performs a logical conversion of alpha-item into the format of dest-item. Dest-item may be any type of data item. This is normally done to convert a character representation of a number into the corresponding numeric value. The rules of conversion are the same as the rules used by the CONVERT option of the ACCEPT statement. For a detailed description of these rules, see section 6.4.9, "Common Screen Options," under the subheading "CONVERT phrase."
15. If the ON EXCEPTION phrase is specified, then statement-1 executes when a conversion error occurs. If a conversion error occurs, then the value assigned to dest-item is the value determined by ignoring the illegal characters in alpha-item. If the NOT ON EXCEPTION phrase is specified, then statement-2 executes when no conversion error occurs.