Wednesday, December 3, 2008

What is the difference between a COBOL subscript and an index ?

An index is defined with it's associated table using the INDEXED BY phrase. Itis a storage area generated by the compiler. It is a register item that exists outside the program's working storage. It is 4 bytes in length. You can’tdisplay an index. The SET statement sets up and down an index,PERFORM VARYING.

A subscript is a positive integer defined in working-storage. It's best to define it as S9(4) COMP. A subscript is changed using ADD, SUBTRACT, MOVE or PERFORM VARYING like any other numeric working storage variable.

For detailed queries on subscript and index click here.

Please do provide your comments or reactions.

No comments: