01 MEMORY-AREA-ONE PIC X(2816). 01 REDEFINES MEMORY-AREA-ONE. 05 K01-1 OCCURS 37 TIMES INDEXED BY K01-1-X PIC 9(04) COMP-5. 05 K02-1 OCCURS 1369 TIMES INDEXED BY K02-1-X PIC 9(04) COMP-5. The previous was nearly there! COMP-5 is machine dependant. So on a little endian machine (eg x86) it will be backwards compared to a big endian machine link AIX. On big endian machines, COMP/COMP-4 and COMP-5 end up being the same thing (usually). COMP-3 is DCD and COMP-1/COMP-2 are poorly defined but often resolve to floating point. In more modern COBOL one would use float-short and float-long to resolve the issues with COMP-1 and COMP-2. PIC 9(04) means an unsigned _decimal_ integer of four digits INDEXED BY defines a working storage element (variable) which works a lot like a subscript to a C array. However, indexes in COBOL in old (very old) days were more efficient because they come pre-computed and avoid multiplications in computing memory offset (as all cpus have hardware multiplication - this is not an issue any more). You move the index by set up by and set down by like with pointers. If you are a C programmer - then just think of redefines like a union and the pain will go away. Also - why does everyone have to make fun of COBOL? I mean - what gives? Just because one does not understand something does not mean it is wrong. C does not even allow the definition of an unsigned 4 digit decimal. However, because such things are required, we have to use horrid library routines to work with them in C. So, despite its age - COBOL has its uses. It is just another language. Good on you for learning it. Take care - AJ www.nerds-central.com - welcomes all nerds :-)
A
alex turner
@alex turner