Using the STRING, UNSTRING, and INSPECT Statements
5.2 Separating Data Using the UNSTRING Statement
Table 5–4 Results of Delimiting with an Asterisk
FIELD1
PIC X(6)
VALUE IS:
FIELD2
PICTURE IS:
FIELD2
Value After
UNSTRING
XXX
ABC
ABCDEF
X(7)
ABCDEF
XXX JUSTIFIED
DEF
******
XXX
###
*ABCDE
XXX
###
A*****
XXX JUSTIFIED
##A
246***
S9999
024F
12345*
S9999 TRAILING SEPARATE
2345+
2468**
S999V9 LEADING SEPARATE
+4680
*246**
9999
0000
Legend: # = space
If the delimiter matches the first character in the sending item, the compiler
considers the size of the sending item to be zero. The operation still takes place,
however, and fills the receiving item with spaces (if it is nonnumeric) or zeros (if
it is numeric).
A delimiter can also be applied to an UNSTRING statement that has multiple
receiving items:
UNSTRING FIELD1 DELIMITED BY SPACE
INTO FIELD2A FIELD2B.
The compiler generates code that scans FIELD1 searching for a character that
matches the delimiter. If it finds a match, it moves the scanned characters
to FIELD2A and sets the scanner to the next character position to the right
of the character that matched. The compiler then resumes scanning FIELD1
for a character that matches the delimiter. If it finds a match, it moves all of
the characters between the character that first matched the delimiter and the
character that matched on the second scan, and sets the scanner to the next
character position to the right of the character that matched.
The DELIMITED BY phrase handles additional items in the same manner as it
handled FIELD2B.
Table 5–5 illustrates the results of the following delimited UNSTRING operation
into multiple receiving items:
UNSTRING FIELD1 DELIMITED BY "*"
INTO FIELD2A FIELD2B.
Using the STRING, UNSTRING, and INSPECT Statements 5–9
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......