Thursday, December 4, 2008

Subscript and Index

What is the difference between a subscript and an index?

An index is defined with it's associated table using the INDEXED BY phrase. It is 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 defineit as S9(4) COMP. A subscript is changed using ADD, SUBTRACT, MOVE orPERFORM VARYING like any other numeric working storage variable.

For more cobol queries, click here

Max no. of dimensions in a cobol array ?

For Cobol 3 is the max where as for Cobol-II 7 is the max.

What is array bounds checking ?

My program has an array defined to have 10 items. Due to a bug , I find that even if he program access the 11th item in the array, the program does not abend. What’s wrong with it?

Must use the compiler option SSRANGE, if u want array bounds checking.Default is NOSSRANGE.

For detailed description of these compiler options. Please refer to the following link COBOL Compiler options