I'm analyzing a survey where I let my client provide names for all her variables (e.g., TAILOR, NETWORK, LIFE, DENTAL). My program automatically made a file description in a copy book, using her variable names as COBOL data names.
The Visual COBOL compiler correctly barfed when it encountered two of her names -- SEPARATE and EXIT -- saying that these could not be used as variable names because they were reserved COBOL words. I changed those to SEPAR and EXINT, and everything seemed to work out all right.
Except that it WASN'T all right. After a certain point into the record, the raw data stopped matching the variable names. Each raw data item was assigned not to the correct variable name, but to the next variable name to the right. The Visual COBOL debugger was no help. I tried everything I could think of, to no avail, for more than two days. Finally, I found the problem when I put in code that displayed the variable name and the variable value for every one of the 550 variables, with code like this:
DISPLAY 'OTADMIN1 ' OTADMIN1 UPON CONSOLE.
DISPLAY 'OTADMIN2 ' OTADMIN2 UPON CONSOLE.
DISPLAY 'OTADMIN3 ' OTADMIN3 UPON CONSOLE.
DISPLAY 'COMP' COMP UPON CONSOLE.
DISPLAY 'COMPMAX ' COMPMAX UPON CONSOLE.
DISPLAY 'COMPUN ' COMPUN UPON CONSOLE.
DISPLAY 'COMPPAY ' COMPPAY UPON CONSOLE.
DISPLAY 'BENFIN1 ' BENFIN1 UPON CONSOLE.
This time, the compiler barfed on the statement "DISPLAY 'COMP ' COMP UPON CONSOLE." saying that "COMP" was a reserved word. Finally!
So I changed 'COMP' to 'COMPTIME', and this time everything really did work.
So, the problem is that, while the compiler correctly flags "COMP" as a reserved word when it is used in a statement, it doesn't flag COMP as an invalid when it is used in a file description or working storage. It just doesn't count as a variable -- throwing every subsequent variable off by one click.
This is a rare problem, but a fix to the compiler would be most welcome.