Skip to content

Instantly share code, notes, and snippets.

@blippy
Created December 12, 2016 09:19
Show Gist options
  • Select an option

  • Save blippy/dd99676cad25b62b29b651a0010b52b6 to your computer and use it in GitHub Desktop.

Select an option

Save blippy/dd99676cad25b62b29b651a0010b52b6 to your computer and use it in GitHub Desktop.
unstring with delimiter in last field
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