The MOVE statement transfers data to data items.
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
- source-item is a literal or data item that represents the sending area.
- dest-item is a data item that receives the data.
- source-group and
dest-group must be group items.
- alpha-item is a literal or data item of class alphanumeric.
- CORR is an abbreviation for CORRESPONDING.
- If
dest-item is numeric or numeric edited,
source-item may not be HIGH-VALUES, LOW-VALUES, SPACES, or QUOTES.
- source-item and
dest-item must be of a compatible category. See General Rule 9 below.
- statement-1 and
statement-2 are imperative statements.
General Rules
- A Format 1 MOVE statement moves source-item to each dest-item in the same order in which they appear in the statement.
- Subscript evaluation for
source-item occurs once before the move to the first
dest-item.
- Subscript evaluation for
dest-item occurs immediately before the move to that item.
- 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.
- The length of
dest-item is computed immediately before the MOVE to that item.
- Reference modification is allowed on source-item and dest-item.
- source-item and
dest-item should not overlap (reference the same location in memory). The compiler does not detect this condition. The results of such
a move are undefined. One possible outcome is a memory access violation. For example:
MOVE myStr(2:myLen - 1) to myStr(1:myLen)
attempts to move part of myStr to myStr, which gives undefined results. Another mistake is to create an overlap by moving
the value of an item to a REDEFINES of the same item.
- 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.
- 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:
- Numeric literals are numeric. Nonnumeric literals are alphanumeric.
- The figurative constant ZERO is numeric when
dest-item is numeric or numeric edited, otherwise it is alphanumeric.
- The figurative constant SPACE is alphabetic.
- All other figurative constants are alphanumeric.
- 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.
- 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:
Sending Category:
|
Receiving Item Category:
|
Alphabetic
|
Alphanumeric/Alphanumeric Edited
|
Numeric /Numeric Edited
|
Alphabetic
|
Yes (12)
|
Yes (13)
|
No (15)
|
Alphanumeric
|
Yes (12)
|
Yes (13)
|
Yes (14)
|
Alphanumeric Edited
|
Yes (12)
|
Yes (13)
|
No (15)
|
Numeric Integer
|
No (15)
|
Yes (13)
|
Yes (14)
|
Numeric
Non-integer
|
No (15)
|
No (15)
|
Yes (14)
|
Numeric Edited
|
No (15)
|
Yes (13)
|
Yes (14)
|
- When
dest-item is alphabetic, justification and space filling occur according to the standard alignment rules.
- 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.
- 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.
- The following moves are illegal:
- An alphabetic or alphanumeric edited data item may not be moved to a numeric or numeric edited data item.
- A numeric or numeric edited data item may not be moved to an alphabetic item.
- A non-integer numeric data item cannot be moved to an alphanumeric or alphanumeric edited data item.
- 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
Common Screen Options, under the subheading
CONVERT phrase.
- 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.