Figure description: UNSTRING statement
This figure illustrates the processing of an UNSTRING statement. The following statement is used in this description:
UNSTRING send-id DELIMITED BY delimiter-id OR ALL "*"
INTO receiver-id1 DELIMITER IN delim-1 COUNT IN cnt1
receiver-id2 DELIMITER IN delim-2
reciever-id3 DELIMITER IN delim-3 COUNT IN cnt3
WITH POINTER pointer-1
TALLYING IN tally-field-1
ON OVERFLOW GO TO overflow-exit.
END-UNSTRING
See the following initial data values:
- Send-id, a 20-character data item of category alphanumeric, contains "123**45678??90ABCDEF".
- Delimiter-id, a one-character data item of category alphanumeric, contains a question mark.
Each receiving delimiter field is one character in length.
The data in Send-id is examined from left to right. See the following processing steps:
- For receiver-id1:
- The three characters 123 are transferred into receiver-id1, and receiver-id1 is padded with blanks to its length (six characters).
- The delimiter asterisk is placed in delim-1. Because
ALL "*"
was specified as the delimiter, both asterisks are used as the delimiter. - Cnt1 is set to the number of characters that were moved (3).
- For receiver-id2:
- The characters 45678 are transferred into receiver-id2, and receiver-id2 is padded with one blank to its length (six characters).
- The delimiter question mark is placed in delim-2.
- For receiver-id3:
- No characters are transferred into receiver-id3 because there are none before the next question mark in send-id.
- The delimiter question mark is placed in delim-3.
- Cnt3 is set to 0.
- For receiver-id4:
- The characters 90ABC are transferred into receiver-id4, a five-character field.
- Cnt4 is set to 8, the number of characters that were examined in send-id.
- Tally-field-1 is set to 5 (the number of fields transferred plus 1).
- Pointer-1 is set to 21 (the length of the sending field plus 1).
The branch to overflow-exit is not taken because all the characters in send-id were examined.
End figure description.