[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

Additional References

6.8.22 MOVE

Function

The MOVE statement transfers data to one or more data areas. The editing rules control data transfer.


src-item

is an identifier that represents the sending area.

lit

is a literal that represents the sending area.

dest-item

is an identifier that represents the receiving area.

Syntax Rules

  1. CORR is an abbreviation for CORRESPONDING.
  2. In the CORRESPONDING phrase, both src-item and dest-item must be group items, and there can be only one dest-item.
  3. If any dest-item is numeric or numeric edited, lit cannot be any of the following:
    • HIGH-VALUE
    • HIGH-VALUES
    • LOW-VALUE
    • LOW-VALUES
    • SPACE
    • SPACES
    • QUOTE
    • QUOTES
  4. If lit is the figurative constant ALL literal and the usage of dest-item is COMP-1 or COMP-2, the MOVE statement uses only one occurrence of literal.
  5. No operand can be an index data item.

General Rules

  1. In Format 2, when the CORRESPONDING phrase is present, selected items in src-item are moved to selected items in dest-item. The rules for the CORRESPONDING option control these moves. The results are the same as if the MOVE statement were replaced by separate MOVE statements for each pair of corresponding items in src-item and dest-item.
  2. In Format 1, the MOVE statement moves the sending area to the first dest-item, then to each additional dest-item, in the same order in which they appear in the statement.
  3. If src-item is reference-modified, subscripted, or indexed, or is a function-identifier, the reference modifier, subscript, index, or function-identifier is evaluated once, immediately before the move to the first dest-item.
  4. Subscript or index evaluation for a dest-item occurs immediately before the move to that item.
  5. The length of src-item is evaluated once, immediately before the move to the first dest-item.
  6. The length of each dest-item is evaluated immediately before the move to that item.
  7. The result of the first of the following MOVE statements is equivalent to the three that follow. The word temp represents an intermediate result item supplied by the compiler.


    MOVE ITEMA (ITEMB) TO ITEMB, ITEMC (ITEMB).
    
    MOVE ITEMA (ITEMB) TO temp.
    MOVE temp TO ITEMB.
    MOVE temp TO ITEMC (ITEMB).
    

Elementary Moves

  1. A move is elementary when dest-item is an elementary item, and the sending area is either an elementary data item or a literal.
    1. An elementary item belongs to one of these categories, depending on its PICTURE clause:
      • Numeric
      • Alphabetic
      • Alphanumeric
      • Numeric edited
      • Alphanumeric edited
    2. Numeric literals are numeric. Nonnumeric literals are alphanumeric.
    3. The figurative constant ZERO is numeric when moved to a numeric or numeric edited item. Otherwise, it is alphanumeric.
    4. The figurative constant SPACE is alphabetic.
    5. All other figurative constants are alphanumeric.
  2. These rules apply to elementary moves between categories:
    1. The figurative constant SPACE, or an alphanumeric edited or alphabetic data item, cannot be moved to a numeric or numeric edited data item.
    2. A numeric literal, the figurative constant ZERO, or a numeric or numeric edited data item, cannot be moved to an alphabetic data item.
    3. A noninteger numeric literal or data item cannot be moved to an alphanumeric or alphanumeric edited data item.
    4. All other elementary moves are valid.

Editing, De-Editing, and Data Conversion During Elementary Moves

  1. Editing, de-editing, or other required internal data conversions occur during elementary moves. They are controlled by the description of dest-item.
  2. When dest-item is alphanumeric or alphanumeric edited, alignment and space-filling occur according to the Standard Alignment Rules.
    If lit or src-item is signed numeric, the operational sign is not moved. If the operational sign occupies a separate character position:
    1. The sign character is not moved.
    2. The size of lit or src-item is considered to be one less than its actual size (in terms of Standard Data Format characters).

    If the sending operand is numeric and contains the PICTURE symbol (P), all digit positions specified with this symbol are considered to have the value zero and are counted in the size of the sending operand.
  3. When dest-item is numeric or numeric edited, decimal point alignment and zero-filling occur according to the Standard Alignment Rules.
    1. When dest-item is a signed numeric item, the sign from lit or src-item is placed in it. If the sending item is unsigned, a positive sign is placed in dest-item.
    2. When dest-item is an unsigned numeric item, the absolute value of lit or src-item is moved.
    3. When lit or src-item is alphanumeric, the move occurs as if the sending item were described as an unsigned numeric integer.
    4. When src-item is numeric edited, the compiler de-edits it before moving it to dest-item. Src-item can be signed.
  4. When dest-item is alphabetic, justification and space-filling occur according to the Standard Alignment Rules.

Nonelementary Moves

  1. A nonelementary move occurs as if it were an alphanumeric-to-alphanumeric elementary move. However, there is no internal data conversion. The move is not affected by individual elementary or group items in either src-item or dest-item, except as noted in the General Rules for the OCCURS clause.

Summary

Table 6-13 summarizes the valid types of MOVE statements. References after slash marks show the applicable General Rule. For example, moving a numeric edited item to an alphabetic item is invalid because of General Rule 9b.

Table 6-13 Valid MOVE Statements
  Category of Receiving Data Item (dest-item)
Category of Sending
Data Item
(lit or src-item)
Alphabetic Alphanumeric Edited
Alphanumeric
Numeric Integer
Numeric Noninteger
Numeric Edited
Alphabetic Yes/13 Yes/11 No/9a
Alphanumeric Yes/13 Yes/11 Yes/12
Alphanumeric Edited Yes/13 Yes/11 No/9a
Numeric Integer No/9b Yes/11 Yes/12
Numeric Noninteger No/9b No/9c Yes/12
Numeric Edited No/9b Yes/11 Yes/12

Additional References

Examples

The following examples show the result of executing the statement:


MOVE ITEMA TO ITEMB.

An s indicates a space character.

  • Numeric edited receiving item:
    (The PICTURE of ITEMA is S9999V99.)
      ITEMA
    Value
    ITEMB
    PICTURE
    ITEMB
    Contents
    a. +0023.00 ZZZZ.99 ss23.00
    b. -0036.93 ++++.99 s-36.93
    c. +1234.56 Z,ZZZ.99 1,234.56
    d. +1234.56 Z,ZZZ.99- 1,234.56s
    e. +1234.56 Z,ZZZ.99+ 1,234.56+
    f. -1234.56 $,$$$,$$$.99DB sss$1,234.56DB
    g. -1234.56 $,$$$.99- s$234.56-
    h. +0001.25 $,$$$.99 sss$1.25
    i. -0001.25 $,$$$.99 sss$1.25
    j. +0000.00 $,$$9.99 sss$0.00
    k. +0000.00 $,$$$.$$ ssssssss


    Previous Next Contents Index