INDICATOR USAGE


Indicators were used extensively in early RPG programming to control program logic, identify input, condition output, detect errors, and signal certain "events." Due to support for structured programming constructs, extensive use of indicators is no longer an endorsed programming practice. However, many hundreds of thousands, or perhaps even millions, of RPG application programs have been written. This represents nearly 1 billion lines of RPG code. A large percentage of that code was written prior to structured constructs being added to RPG. These programs have to be maintained. When maintaining these applications, try to convert as much of the application as possible to structured programming. Often, this can be accomplished without affecting the program's overall design.

Nowadays, a typical application program uses fewer than four indicators, unless communicating with a device file necessitates using more. The recommendations for each of the four indicators follow:

  • "Trash" Indicator. The "trash" indicator is used for just about anything. For example, it can be used to condition the ENDDO statement of a DO...ENDDO loop construct or to indicate the result of various operations such as LOOKUP, COMP, SCAN , TEST, MULT, and DIV.

  • Error Indicator. The error indicator is used to signal error conditions such as record locking, device file time-out, or other errors.

  • File Status Indicator. The file status indicator is used to signal various file conditions such as record not found, end of file, or beginning of file. In some cases, such as with small programs, the indicator used as the file indicator also can be used as the error indicator.

  • Program Termination Indicator. Normally, the last record indicator (LR) or the return indicator (RT) is used as the program termination indicator. LR signals that the program should terminate upon reaching the end of calculation specifications or when the return (RETURN) operation is performed. RT, when used independently, signals that the program should end, but remain active in memory at the completion of the calculation specifications.

When communicating with a workstation, printer, or telecommunications device file, the number of indicators being used can increase. This is primarily due to limitations in the technology being used for device-file definition. Also, each function key (i.e., special keys on every keyboard that normally cause an immediate reaction by the program) can result in the use of an additional indicator.




The Modern RPG IV Language
The Modern RPG IV Language
ISBN: 1583470646
EAN: 2147483647
Year: 2003
Pages: 156
Authors: Robert Cozzi

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net