MOVE Statement

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

  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. Reference modification is allowed on source-item and dest-item.
  7. 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.
  8. 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.
  9. 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:
    1. Numeric literals are numeric. Nonnumeric literals are alphanumeric.
    2. The figurative constant ZERO is numeric when dest-item is numeric or numeric edited, otherwise it is alphanumeric.
    3. The figurative constant SPACE is alphabetic.
    4. All other figurative constants are alphanumeric.
  10. 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.
  11. 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)
  12. When dest-item is alphabetic, justification and space filling occur according to the standard alignment rules.
  13. 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.
  14. 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.
  15. The following moves are illegal:
    1. An alphabetic or alphanumeric edited data item may not be moved to a numeric or numeric edited data item.
    2. A numeric or numeric edited data item may not be moved to an alphabetic item.
    3. A non-integer numeric data item cannot be moved to an alphanumeric or alphanumeric edited data item.
  16. 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.
  17. 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.