-
1
- #1
All -
I've recently been "dumpster diving" in some old, production code and turned up a number of common errors that persist in the code to this day. That set me thinking about common traps that COBOL programmers, especially beginners, fall into. I figured that topic might be worthy of a FAQ. Some of my nominees include:
1. A general failure to initialize variables before use.
2. Failing to zero the counter before an INSPECT . . . TALLYING.
3. Failing to initialize the receiving item to spaces before a STRING statement.
4. Moving a group item to an alphanumeric edited item.
5. Failing to set the index appropriately before a SEARCH verb.
6. Failing to use parentheses where needed in logical expressions containing a mixture of logical operators.
7. Failing to check FILE-STATUS after every I/O operation.
Are there other common pitfalls you think I might include?
(Obviously, a well-done FAQ will include examples and additional narrative. I'm simply looking for more problems to include.)
Regards.
Glenn
I've recently been "dumpster diving" in some old, production code and turned up a number of common errors that persist in the code to this day. That set me thinking about common traps that COBOL programmers, especially beginners, fall into. I figured that topic might be worthy of a FAQ. Some of my nominees include:
1. A general failure to initialize variables before use.
2. Failing to zero the counter before an INSPECT . . . TALLYING.
3. Failing to initialize the receiving item to spaces before a STRING statement.
4. Moving a group item to an alphanumeric edited item.
5. Failing to set the index appropriately before a SEARCH verb.
6. Failing to use parentheses where needed in logical expressions containing a mixture of logical operators.
7. Failing to check FILE-STATUS after every I/O operation.
Are there other common pitfalls you think I might include?
(Obviously, a well-done FAQ will include examples and additional narrative. I'm simply looking for more problems to include.)
Regards.
Glenn