COBOL Manual for TNS/E Programs (H06.03+)

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-245
STRING
Usage Considerations:
Operand Identification
For each identifier, the process of operand identification occurs only once, at the
beginning of the execution of the STRING statement.
Initialization
The execution of the STRING statement begins in this manner:
1. The data item specified by result is established as the receiving item.
2. When the POINTER phrase appears, the data item specified by pointer is
established as the pointer variable.
If the initial value of pointer is less than 1 or greater than the size of the
receiving item, then the overflow condition exists immediately and no string
operation occurs; otherwise, the initial value of pointer determines the
relative character position within result at which the first sending value is
assigned. The leftmost character position is designated to be 1.
When the POINTER phrase does not appear, the string operation presumes an
initial relative character position of 1.
String Operation Cycle
The string operation transfers data from each part-1, in the same order as they
are specified in the STRING statement. The steps involved in the transfer of a
sending value are:
°
Determining the transfer string
If the applicable DELIMITED phrase specifies delimiter, then the value of
the current part-1 is examined character by character from left to right until
either of these is found: the end of the value, or a sequence of contiguous
characters that matches the value of delimiter.
If a match is found, the transfer string consists of the portion of the sending
value preceding the character that matches the first character of the delimiter;
otherwise, the transfer string consists of the entire sending value.
If the applicable DELIMITED phrase specifies SIZE, then no delimiter exists
and the transfer string always consists of the entire sending value.
°
Copying the transfer string to the receiving item
Assignment of the transfer string to the receiving item (result ) proceeds on a
character by character basis. Beginning with the leftmost character, each character
of the transfer string is moved into the receiving item character position designated
by the pointer value, which is incremented by 1 after each character is moved.