Created
December 12, 2016 09:19
-
-
Save blippy/dd99676cad25b62b29b651a0010b52b6 to your computer and use it in GitHub Desktop.
unstring with delimiter in last field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 001000 IDENTIFICATION DIVISION. | |
| 001010 PROGRAM-ID. ustr. | |
| 002000 ENVIRONMENT DIVISION. | |
| 003000 DATA DIVISION. | |
| 003020 WORKING-STORAGE SECTION. | |
| 01 input-string pic x(30). | |
| 01 ptr-last-field pic 99. | |
| 01 field1 pic x(20). | |
| 01 field2 pic x(20). | |
| 01 field3 pic x(20). | |
| 003030 LOCAL-STORAGE SECTION. | |
| 003040 LINKAGE SECTION. | |
| 004000 PROCEDURE DIVISION. | |
| program-begin. | |
| move "how now brown cow" to input-string | |
| move 1 to ptr-last-field | |
| unstring input-string delimited by all spaces | |
| into field1, field2 with pointer ptr-last-field | |
| end-unstring. | |
| move input-string(ptr-last-field:) to field3 | |
| display "field1:", field1 | |
| display "field2:", field2 | |
| display "field3:", field3 | |
| stop run. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment