COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-278
UNSTRING
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.
If you execute
UNSTRING U DELIMITED BY SPACE
INTO WORD-1 WORD-2 WORD-3
WORD-4 WORD-5 WORD-6
The fifth item to be copied is “handy.” There is no sixth item to be copied.
The unstring operation handles the set of characters thus examined (excluding
the delimiter string, if any) as an elementary alphanumeric data item and
copies it to the current receiving area in accordance with the rules for the
MOVE statement. When the set contains no characters (that is, if a delimiter
string begins at the very first character examined in this cycle), the unstring
operation moves a null value to the current receiving area. If the current
receiving area is described as numeric or numeric-edited, the value 0 is
moved; otherwise the value spaces is moved.
If you include a DELIMITER phrase in the INTO phrase for this cycle, the
unstring operation handles the set of characters in the delimiter string as an
elementary alphanumeric data item and copies it to delimstore in
accordance with the rules for the MOVE statement. If the delimiting condition is
the end of the sending area (that is, there is no delimiter string), then the
unstring operation fills the delimiter data item with spaces.
If the delimiter is described as a figurative constant with the ALL qualifier, only
one occurrence of the unqualified figurative constant is moved.