COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
UNSTRING U DELIMITED BY SPACE
INTO WORD-1 WORD-2 WORD-3
WORD-4 WORD-5 WORD-6
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.
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
UNSTRING 479










