Data flow
When the STRING statement is executed, characters are transferred from the sending fields to the receiving field. The order in which sending fields are processed is the order in which they are specified.
The following rules apply:
- Characters
from the sending fields are transferred to the receiving
fields in the following manner:
- For national sending fields, data is transferred using the rules of the MOVE statement for elementary national-to-national moves, except that no space filling takes place.
- For DBCS sending fields, data is transferred using the rules of the MOVE statement for elementary DBCS-to-DBCS moves, except that no space filling takes place.
- Otherwise, data is transferred to the receiving fields using the rules of the MOVE statement for elementary alphanumeric-to-alphanumeric moves, except that no space filling takes place (see MOVE statement).
- When DELIMITED BY identifier-2 or literal-2 is
specified, the contents of each sending item are transferred, character-by-character,
beginning with the leftmost character position and continuing until
either:
- A delimiter for this sending field is reached (the delimiter itself is not transferred).
- The rightmost character of this sending field has been transferred.
- When DELIMITED BY SIZE is specified, each entire sending field is transferred to the receiving field.
- When the receiving field is filled, or when all the sending fields have been processed, the operation is ended.
- When the POINTER
phrase is specified, an explicit pointer field
is available to the COBOL user to control placement of data in the
receiving field. The user must set the explicit pointer's initial
value, which must not be less than 1 and not more than the character
position count of the receiving field.
Usage note: The pointer field must be defined as a field large enough to contain a value equal to the length of the receiving field plus 1; this precludes arithmetic overflow when the system updates the pointer at the end of the transfer.
- When the POINTER phrase is not specified, no pointer is available to the user. However, a conceptual implicit pointer with an initial value of 1 is used by the system.
- Conceptually, when the STRING statement is executed, the initial pointer value (explicit or implicit) is the first character position within the receiving field into which data is to be transferred. Beginning at that position, data is then positioned, character-by-character, from left to right. After each character is positioned, the explicit or implicit pointer is increased by 1. The value in the pointer field is changed only in this manner. At the end of processing, the pointer value always indicates a value equal to one character position beyond the last character transferred into the receiving field.
After STRING statement execution is completed, only that part of the receiving field into which data was transferred is changed. The rest of the receiving field contains the data that was present before this execution of the STRING statement.