The Bad and the Ugly (Indicators- Part 1)

For the uninitiated, indicators are essentially Boolean variables which, until recently were defined automatically by the RPG compiler. (With RPGIV, you can now define your own named indicators. See this article for details.)

The system defined indicators are named by the digits 01-99, which may be defined by the programmer, L1-L9 to define level breaks(where changes in input data are automatically detected by the program), MR (used when matching file reads with similar keys), halt indicators H1-H9 to halt the program when an error occurs, and overflow indicators OA-OG and OV to flag when a printout is at end of page and ready to go to the next.

The trend today is to totally swear off indicator usage in RPG programs. This is understandable. Misused indicators have been the cause of many programmer headaches or worse. You’ve never lived until you’ve tried to get your head around a 10000 line RPG program that uses all 99 numbered indicators in calculations, and as many as possible in the output. You find yourself frantically turning from line 2000 to line 8763, trying to find out what on earth is the significance of indicator 56, or when it is true that indicators 45, 65, and 67 are on and 33 and 89 are off, with even fields in the output conditioned by up to three indicators.

Or how about these calculations and output?

 
C           X             COMP 25                   253746
C  N25N37   Y             COMP 36                   161514
C   25 46 16Z             COMP 83                   1726
C   26 16 25CUST#         CHAINCSTMST               12
OCUSTMSTRE         17 16        OUTPUT
O                  25 27 46     FIELD1   45
O                  37 15 46     FIELD1   50
O                  14 27 46     FIELD1   45
O                        12              57 'NOT ON FILE' 

There’s just too much going on in one line of code.
So when people want to get rid of indicators entirely, you can understand. But do such programs prove the point that indicators must be gotten rid of at all costs?
Well, not necessarily. It depends……

Leave a Reply