STRING and UNSTRING
| STRING | |
| UNSTRING | |
| WITH POINTER |
STRING
STRING joins fields into one target, moving characters until the target is full. DELIMITED BY SIZE copies a whole field, and DELIMITED BY SPACE stops at the first space:
STRING WS-FIRST-NAME DELIMITED BY SPACE
" " DELIMITED BY SIZE
WS-LAST-NAME DELIMITED BY SIZE
INTO WS-FULL-NAME.
UNSTRING
UNSTRING splits a source field into targets, breaking at a delimiter. DELIMITED BY "," reads CSV-style input, and the delimiter itself is discarded:
UNSTRING WS-LINE DELIMITED BY ","
INTO WS-NAME WS-CITY WS-ZIP.
WITH POINTER
WITH POINTER tracks the character position, so UNSTRING can continue where the last one stopped. TALLYING counts how many fields were filled, which catches short input lines:
UNSTRING WS-LINE DELIMITED BY ","
INTO WS-A WS-B WS-C
TALLYING WS-FILLED.
Next: Files: SELECT and FD
Article author: Arthur Isaev