Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 9405

COBOL Programming :: RE: Unstring list of values into an array.

$
0
0
Author: dbzTHEdinosauer
Posted: Mon Jun 27, 2016 8:42 pm (GMT 5.5)

you have a table, starting at position 5, with variable item length.

what is the maximum length of city?
add 1 (for the '#' ) and multiply that by 40, giving you the length of the AREA to which you move your string from position 5.

then define your receiving table TABLE as a fixed length table of 40 items,
each item with a max possible length of CITY.

then redefine your TABLE with element fields (each of item length) as ITEM-1, ITEM-2, ...ITEM-40.

now you only need one UNSTRING statement, (delimiting by '#' or space)
UNSTRING AREA DELIMITED BY ... INTO ITEM-1, ITEM-2...,ITEM-40
and no loop.

either spend your time using field declarations, thus requiring only one instruction and no loop

or spend some time figuring out how to write a loop, that won't drive you crazy trying to debug.
_________________
Dick Brenholtz

Programming Languages, SQL and JCL have the tendency to do what you coded,
not necessarily what you wanted.


Viewing all articles
Browse latest Browse all 9405

Trending Articles