6 using the move statement – Compaq COBOL AAQ2G1FTK User Manual

Page 117

Advertising
background image

Handling Nonnumeric Data

3.5 Data Movement

receiving item must first be described with the JUSTIFIED clause.) Characters
from the middle of the sending item cannot easily be moved to any receiving item
without extensive redefinitions of the sending item or a reference modification
loop (as with concatenation).

The STRING and UNSTRING statements handle concatenation and dispersion
more easily than compound moves. Reference modification handles substring
operations more easily than compound moves, STRING, or UNSTRING.

3.6 Using the MOVE Statement

The MOVE statement moves the contents of one item into another. For example:

MOVE FIELD1 TO FIELD2

MOVE CORRESPONDING FIELD1 TO FIELD2

FIELD1 is the sending item name, and FIELD2 is the receiving item name.

The first statement causes the compiler to move the contents of FIELD1 into
FIELD2. The two items need not be the same size, class, or usage; they can be
either group or elementary items. If the two items are not the same length, the
compiler aligns them on one end or the other. It also truncates or space-fills the
other end. The movement of group items and nonnumeric elementary items is
discussed in Section 3.6.1 and Section 3.6.2, respectively.

The MOVE statement alters the contents of every character position in the
receiving item.

3.6.1 Group Moves

If either the sending or receiving item is a group item, the compiler considers the
move to be a group move. It treats both the sending and receiving items as if
they were alphanumeric items.

If the sending item is a group item, and the receiving item is an elementary item,
the compiler ignores the receiving item description except for the size description,
in bytes, and any JUSTIFIED clause. It conducts no conversion or editing on the
sending item’s data.

3.6.2 Elementary Moves

If both items of a MOVE statement are elementary items, their PICTURE
character-strings control their data movement. If the receiving item was
described as numeric or numeric edited, the rules for numeric moves control the
data movement (see Section 2.6). Nonnumeric receiving items are alphanumeric,
alphanumeric edited, or alphabetic.

Table 3–2 shows the valid and invalid nonnumeric elementary moves.

Handling Nonnumeric Data 3–7

Advertising