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

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-263
UNSTRING
the first item to be copied is “The” and the second is “UNSTRING” and so on.
If you specify two or more delimiters, the unstring operation compares their
values with the sending area in the same order as they appear in the phrase. If
a match occurs, the corresponding set of characters in the sending area forms
the delimiter string; any delimiters not yet tested are ignored. If no delimiter
value matches the sending area at the current position, the unstring operation
repeats the delimiter search beginning with the next character of the sending
area. No character in the sending area can be considered a part of more than
one delimiter.
If you execute
UNSTRING U DELIMITED BY SPACE OR "I"
INTO WORD-1 WORD-2 WORD-3
WORD-4 WORD-5 WORD-6
the first item to be copied is “The,” the second item is “UNSTR,” the third is
“NG,” and so on.
Two special cases are consecutive delimiters and multicharacter delimiters.
If ALL was not specified and the unstring operation encounters two
consecutive delimiters, it interprets the sending item as zero if result is
numeric. If result is not numeric, the unstring operation interprets the
sending item as spaces.
Each instance of delim-1 or delim-2 represents one delimiter. When a
delimiter contains two or more characters, all of the characters must be present
in contiguous positions in the source item, and in the order given, to be
recognized as a delimiter.
If you omit the DELIMITED phrase, the examination proceeds left to right until
the number of characters examined equals the size of the current receiving
area.
If you execute
UNSTRING U INTO WORD-1 WORD-2 WORD-3
WORD-4 WORD-5 WORD-6
the first item to be copied is “The UNST,” the second item is “RING state,” and
so on.
If the result item is numeric and its operational sign occupies a separate
character position, the number of characters the unstring operation examines
(when you omit the DELIMITED phrase) is one less than the size of the item.
If the unstring operation reaches the end of the source item before it detects
a matching delimiter (for the DELIMITED phrase), or before it fills all the
receiving items, the examination terminates with the last character examined.