| |
| |
 |
|
| |
COBOL TUTORIAL
FOR BCA STUDENTS OF M G UNIVERSITY |
|
| |
|
|
| |
 |
|
| |
|
| |
|
| |
MOVE verb is used to move data from
one place to another place in memory.
|
|
| |
|
| |
The general form of the MOVE verb
is as follows:
|
|
| |
|
|
| |
|
| |
Data movement is governed by the following rules:
|
|
| |
The
contents of identifier – 1 or the value of literal
– 1 is moved to identifier – 2, identifier
– 3, etc. Note that there may be more than one
receiving field whereas there must be only one sending
field, the contents of all the receiving fields will
be replaced by the value of the sending field. The
contents of identifier – 1 remain unaltered.
|
|
| |
When the sending field is numeric
and the receiving field is numeric or numeric edited
(i.e., picture contains edit symbols) the data movement
is called numeric data transfer. In such cases the
dominant factor in the movement is the alignment of
the decimal points of the two fields. For the purpose
of this alignment, the numeric fields for which the
position of the decimal point is not explicitly indicated,
the decimal point is assumed to be at the right of
the rightmost digit. If the receiving field is not
large enough to hold the data received, truncation
can take place at either and depending on whether
the integral part, fractional part or both can or
cannot be accommodated (see examples given in this
section for further clarification). However, if significant
integral positions are likely to be lost, a warning
to that effect is issued by the compiler. On the other
hand, if the receiving field is larger than the sendingfield,
zero-fill will take place in the unused positions
to keep the numeric value unaltered.
|
|
| |
When both the sending and receiving
fields are alphabetic, alphanumeric or alphanumeric
edited, the data movement is called alphanumeric data
transfer. In such cases the receiving area is filled
from left to right and space fill occurs to the right
if the receiving area is larger than the sending field.
When the receiving area is smaller, truncation occurs
from the right and the compiler gives a warning to
that effect.
|
|
| |
Ideally,
both the sending and receiving fields should belong
to the same category. However, quite often it becomes
necessary to transfer a data to a field having a different
category. Identifier – 1, identifier –
2, identifier – 3, etc., can be group items.
In such cases, the move is very frequently used. This
is when we wish to initialize a record area by spaces.
For example, the statement MOVE SPACES TO REC-AREA
will space-fill the entire area denoted by the group
name REC-AREA.
|
|
| |
|
| |
|
|
| |
|
| |

|
|
| |
|
| |
|
| |
In this case the number 15 will be moved to A and
if the PICTURE of A is 999, then after the execution
of the above statement A will contain 015.
|
|
| |
|
| |
From quotes to quotes the total number of characters
including space is 17. since this is
a nonnumeric literal, all the 17 characters will be
moved to A from left to right if the
PICTURE of A is X(17).
|
|
| |
|
| |
If the contents of A is 22 and the contents of B,
C and D are 452, 3892 and 46 respectively, then after
the execution of the above instruction the contents
of B, C and D will be 022, 0022 and 22 respectively.
The above mentioned rules for data movement are also
used elsewhere in COBOL.
For example, when the value of a data item is initialized
by using the VALUE clause, the same rules apply. In
this case the data name should be considered as the
receiving field and the value of the literal should
be taken as that of the sending field.
Thus,
77 NEW-DATA PIC X(10) VALUE “NEWDATA”
will initialize NEW-DATA by the value NEWDATA  
|
|
| |
|
|
| |
 |
|
| |
|
|
| |
 |
|
| |
|
|
|
|