Wednesday, 15 May 2013

indexing - COBOL expression as index in table array -



indexing - COBOL expression as index in table array -

just short quick question. how index look cobol array? example, if index k=1, next find element of k=2

element(k+1)

unfortunately not acceptable in cobol , know if there alternative?

i'm not sure why think won't work, long set in cobol statement.

id division. program-id. submod. info division. working-storage section. 01 a-nicely-named-table. 05 filler occurs 2 times. 10 a-nicely-named-entry pic x. 01 another-piece-of-data pic x value space. 01 a-nicely-named-subscript binary pic 9(4). linkage section. 01 l-input pic x(4). 01 l-to-hex pic bxbxbxbx. procedure partition using l-input l-to-hex. move "a" a-nicely-named-entry ( 1 ) move "b" a-nicely-named-entry ( 2 ) move 1 a-nicely-named-subscript if a-nicely-named-entry ( a-nicely-named-subscript + 1 ) equal "b" move a-nicely-named-entry ( a-nicely-named-subscript + 1 ) another-piece-of-data end-if display ">" another-piece-of-data "<" goback .

output is:

>b<

with reference comment, not "strictness" thing means. "+ 1" 1 thing, "relative subscript", , "+1" else, sec subscript.

depending on compiler, may able code:

move element(k++1) ...

you may have set moaning compiler, , suppose in may not work. would, however, horrible way write cobol.

i'd suggest not using names element. @ point in future appear "reserved word" cobol. don't shorthand. utilize names, utilize effective spacings. it'll help understand programme little later, , help else has @ it.

arrays indexing cobol

No comments:

Post a Comment