General Formats (Cont.) [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation
Micro Focus COBOL Language Reference
General Formats (Cont.)
The MOVE Statement
Function.
The MOVE statement transfers data, in accordance with the rules of
editing, to one or more data areas.
General Formats.
Format 1.
Format 2.
Directives.
1. In addition to system directives which provide flagging and modify
the reserved word list, the following directives may impact either
the syntax or semantics described in this section. See your COBOL
System Reference for details.
* BYTE-MODE-MOVE - impacts the behavior of MOVE statements in
which the sending and receiving items share a part of their
storage (that is, overlapping moves).
* DBCS (DBSPACE) - impacts what characters are used for space
filling DBCS receiving items.
* DE-EDIT - controls whether the value of numeric-edited
sending fields is determined by their PICTURE clause or
not.
* TRUNC - determines when the sending item includes a value
larger than a binary receiving values size, whether
truncation occurs based on the storage available or the
PICTURE clause.
Syntax Rules.
All Formats.
1. Identifier-1 and literal represent the sending area; identifier-2
represents the receiving area.
2. An index data item or pointer data item or procedure pointer item,
(MF and VSC2 only) cannot appear as an operand of a MOVE
statement. (See the section The USAGE Clause earlier in this
chapter).
3. For VSC2 and MF only: If either the sending or receiving item is
a DBCS (USAGE DISPLAY-1) item, then both must be DBCS items. The
figurative constant SPACE can be the DBCS sending item.
Format 1.
4. For OSVS, VSC2 and MF only: When Format 1 is specified, all
identifiers can be either group or elementary items. The data in
the sending area is moved into the data item referenced by each
identifier-2 in the order in which it is specified.
5. For MF only: Identifier-1 may be a numeric function-identifier.
Format 2.
6. CORR is an abbreviation for CORRESPONDING.
7. When the CORRESPONDING phrase is used, all identifiers must be
group items.
8. For VSC2 and MF only: A pointer data item can be part of a group
that is referenced to in a MOVE CORRESPONDING statement; however,
no movement of the pointer data item will take place.
General Rules.
All Formats.
1. For MF only: If identifier-1 is a numeric function-identifier,
then identifer-2 must be either a numeric or numeric edited item.
2. The data designated by the literal or identifier-1 is moved to the
data item referenced by each identifier-2, in the order in which
it is specified. The rules referring to identifier-2 also apply
to the other receiving areas. Any subscripting or indexing
associated with identifier-2, is evaluated immediately before the
data is moved to the respective data item.
For ANS85 only: If identifier-1 is reference modified,
subscripted, or is a function- identifier, the reference modifier,
subscript, or function-identifier is evaluated only once,
immediately before data is moved to the first of the receiving
operands.
The result of the statement:
MOVE a(b) TO b, c(b)
is equivalent to:
MOVE a(b) TO temp *MOVE temp TO b *MOVE temp TO c(b)
where temp is an intermediate result item provided by your COBOL
system.
3. Any MOVE in which the sending and receiving items are both
elementary items is an elementary move. Every elementary item
belongs to one of the following categories: numeric,
alphabetic, alphanumeric, numeric edited, alphanumeric edited or
floating-point (VSC2, OSVS, and MF). These categories are
described in the PICTURE clause. Numeric literals belong to the
category numeric, and nonnumeric literals belong to the category
alphanumeric. The figurative constant ZERO belongs to the
category numeric when moved to a numeric or numeric-edited item.
The figurative constant ZERO belongs to the category alphanumeric
in all other cases. The figurative constant SPACE belongs to the
category alphabetic. All other figurative constants belong to the
category alphanumeric.
The following rules apply to an elementary move between these
categories:
a.
i. The figurative constant SPACE, or an alphanumeric
edited, or alphabetic data item must not be moved to
a numeric or numeric edited data item.
ii. A numeric edited data item must not be moved to a
numeric or numeric edited data item.
For ANS85 only: This restriction is removed.
b. A numeric literal, the figurative constant ZERO, a numeric
data item or a numeric edited data item must not be moved
to an alphabetic data item.
c. A non-integer numeric literal or a non-integer numeric
data item must not be moved to an alphanumeric or
alphanumeric-edited data item.
d. All other elementary moves are legal and are performed
according to the rules given in General Rule 5.
4. Any necessary conversion of data from one form of internal
representation to another takes place during legal elementary
moves, along with any editing specified for ,or de-editing implied
by, (ANS85) the receiving data item:
a. When an alphanumeric edited or alphanumeric item is a
receiving item, alignment and any necessary space filling
takes place as defined in the section Standard Alignment
Rules in the chapter Concepts of the COBOL Language. If
the size of the sending item is greater than the size of
the receiving item, the excess characters are truncated on
the right after the receiving item is filled. If the
sending item is described as being signed numeric, the
operational sign will not be moved; if the operational sign
occupies a separate character position (see the section The
SIGN Clause earlier in this chapter), that character will
not be moved and the size of the sending item will be
considered to be one less than its actual size (in terms of
standard data format characters).
b. When a numeric or numeric edited item is the receiving
item, alignment by decimal point and any necessary
zero-filling takes place as defined in the section Standard
Alignment Rules in the chapter Concepts of the COBOL
Language, except where zeros are replaced because of
editing requirements.
For ANS85 only: When the sending operand is numeric
edited, de-editing is implied to establish the operand's
unedited numeric value, which can be signed; then the
unedited numeric value is moved to the receiving field.
The effect of de-editing depends on the setting of the
DE-EDIT directive (see your COBOL System Reference for
details).
When a signed numeric item is the receiving item, the sign
of the sending item is placed in the receiving item. (See
the section The SIGN Clause earlier in this chapter.)
Conversion of the representation of the sign takes place as
necessary. If the sending item is unsigned, a positive
sign is generated for the receiving item.
When an unsigned numeric item is the receiving item, the
absolute value of the sending item is moved and no
operational sign is generated for the receiving item.
When a data item described as alphanumeric is the sending
item, data is moved as if the sending item were described
as an unsigned numeric integer.
When the receiving item is numeric or numeric-edited and
the sending item is defined as alphanumeric, if the content
of the sending item is not an integer, the results of the
move are undefined. If the alphanumeric sending item is a
literal whose contents do not represent an integer, an
error will be reported, and zero moved to the target. (See
the section Incompatible Data earlier in this chapter.)
For ANS85 only: When the numeric data item is the sending
item the action of the move will be such that a reverse of
the move would cause the same value to appear in the
numeric edited field (except for truncation). If the data
item contains data which does not conform to the edited
picture, zero is moved to the target.
c. When a receiving field is described as alphabetic,
justification and any necessary space-filling takes place
as defined in the section Standard Alignment Rules in the
chapter Concepts of the COBOL Language. If the size of the
sending item is greater than the size of the receiving
item, the excess characters are truncated on the right
after the receiving item is filled.
d. For OSVS, VSC2, and MF only: When the receiving field is
floating-point, the sending item is converted first to
internal floating-point and then moved. When data is moved
to or from an external floating-point item, the data is
converted first to or from its equivalent internal
floating-point value.
e. For VSC2, and MF only: When the receiving field is DBCS
the sending item must also be DBCS; no conversion takes
place. If the sending and receiving items are not the same
size the data item will be either truncated or padded with
DBCS spaces on the right.
5. Any move that is not an elementary move is treated exactly as if
it were an alphanumeric to alphanumeric elementary move,
except that no conversion of data from one form of internal
representation to another takes place. In such a move, the
receiving area will be filled without consideration for the
individual elementary or group items contained in either the
sending or receiving area, except as noted in the General Rules of
the OCCURS clause.
6. Table 4-13 summarizes the legality of the various types of MOVE
statements. The general rule reference indicates the rule that
prohibits the move or the behavior of a legal move.
Format 2.
7. If the CORRESPONDING phrase is used, selected items in
identifier-1 are moved to selected items in identifier-2,
according to the rules given in the section The CORRESPONDING
Phrase earlier in this chapter. The results are the same as if
the user had referred to each pair of corresponding identifiers
in separate MOVE statements.
For OSVS and VSC2 only: The process is repeated for each
destination group.
Table 4-13 : MOVE Statement Data Categories
------------------------------------------------------------
| |
| Category Category of Receiving Data Items (1) |
| of |
| Sending |
| Item |
| |
------------------------------------------------------------
| |
| Alphabetic Alpha- Numeric Numeric- DBCS |
| numeric- Integer Edited |
| Edited Non- External |
| Alpha- Integer Interanl |
| numeric Floating |
| Point |
| |
| Alphabetic Yes/4c Yes/4a No/3a No/4a No/4e |
| |
| Alpha- Yes/4c Yes/4a Yes/4b(2) Yes/4b No/4e |
| numeric |
| |
| Alpha- Yes/4c Yes/4a No/3a No/3a No/4e |
| numeric- |
| Edited |
| |
| Numeric: No/3b Yes/4a Yes/4b Yes/4b No/4e |
| Integer |
| |
| Non- No/3b No/3c Yes/4b Yes/4b No/4e |
| Integer |
| |
| Numeric- No/3b Yes/4a Yes/4b Yes/4b No/4e |
| Edited |
| |
| DBCS No/4e No/4e No/4e No/4e Yes/4e |
| |
------------------------------------------------------------
(1) The relevant rule number is quoted in these columns
(2) An error will be reported if a non-integer alphanumeric literal
sending item is used
The MULTIPLY Statement
Function.
The MULTIPLY statement causes numeric data items to be multiplied and
sets the values of data items equal to the results.
General Formats.
Format 1.
Format 2.
Syntax Rules.
All Formats.
1. Each identifier must refer to a numeric elementary item, except
that in Format 2 each identifier following the word GIVING must
refer to either an elementary numeric item or an elementary
numeric edited item.
2. Each literal must be a numeric literal.
3. The composite of operands, which is that hypothetical data item
resulting from the superimposition of all receiving data items
aligned on their decimal points, must not contain more than 18
digits.
4. For OSVS, VSC2, and MF only: Floating-point data items and
literals can be used anywhere a numeric data item or literal can
be specified.
General Rules.
All Formats.
1. See the sections The ROUNDED Phrase, The ON SIZE ERROR Phrase,
Arithmetic Statements, Overlapping Operands and Multiple Results
In Arithmetic Statements in this chapter.
Format 1.
2. When Format 1 is used, the value of identifier-1 or literal-1 is
multiplied by the value of identifier-2. The value of the
multiplier (identifier-2) is replaced by this product; similarly
for each successive occurrence of identifier-2 in the
left-to-right order in which identifier-2 is specified.
Format 2.
3. When Format 2 is used, the value of identifier-1 or literal-1 is
multiplied by identifier-2 or literal-2 and the result is stored
in the data item referenced by each identifier-3.
For MF only: The NEXT SENTENCE Statement
Function.
The NEXT SENTENCE statement transfers control to the next COBOL sentence,
that is, following the next period. It does not transfer control to the
logically next COBOL verb as occurs with the CONTINUE verb.
General Format.
Syntax Rule.
The NEXT SENTENCE statement can be used anywhere a conditional statement
or an imperative-statement can be used.
General Rule.
The NEXT SENTENCE statement redirects the flow of the program to the
logically next COBOL verb following the next period.
For OSVS only: The NOTE Statement
Function.
The NOTE statement introduces a sentence or paragraph that will be
treated as comments.
General Format.
Syntax Rule.
The character-string can be any combination of characters from the
computer character set.
General Rules.
1. If a NOTE statement is the first sentence of a paragraph, the
entire paragraph is treated as comment.
2. If a NOTE statement appears as other than the first sentence of a
paragraph, text up to the next separator period is treated as
comment.
For OSVS only: The ON Statement
Function.
The ON statement allows selective execution of procedural statements on a
periodic basis.
General Format.
Syntax Rules.
1. Identifier-1, identifier-2 and identifier-3 must describe unsigned
integer numeric elementary items.
2. Literal-1, literal-2 and literal-3 must be unsigned numeric
literals.
General Rules.
1. Prior to the first execution of each ON statement in the program,
a counter, implicitly defined for that ON statement (the
implicit-ON-counter), is initialized to be zero.
2. Identifier-1, identifier-2 and identifier-3 should, if specified,
contain positive integer values at the time of execution of the ON
statement. Varying these values between executions of the ON
statement will affect subsequent executions of the ON statements.
3. The implicit ON counter cannot be affected in any way other than
by transfer of program execution flow to that ON statement. (The
ON counter of a called program can only be reset by the cancelling
of that program; execution of the EXIT PROGRAM statement and
subsequent CALL of the program without intervening CANCEL has no
effect upon the implicit ON counter value.)
4. The following value-list is then evaluated:
a. the current value of identifier-1 or literal-1,
b. a sequence of values being the results of repeatedly adding
the current value of identifier-2 or literal-2 to the
current value of identifier-1 or literal-1 until the value
of identifier-3 or literal-3 is reached.
The implicit-ON-counter is then compared with each of this list of
values. If an equality is found, then imperative- statement-1 is
executed. If no equality is found, then imperative-statement-2 if
specified, is executed.
MPE/iX 5.0 Documentation