Goodbye, Indicators!

During a lab session at the COMMON conference in Denver, we were surprised at the number of RPG IV programmers who seemed to have missed a significant event in the evolution of the language-namely, the death of the indicator. Or, to be more specific, the death of the *IN series of 99 numbered indicators. We consider this a great step forward in increasing the readability of RPG code. First came mixed case and field names longer than six characters, expressions and now, indicators with names.

The indicators days became numbered in V4R2, when new built-in functions (BIFs) and named indicators first made it possible to write nearly all RPG programs without using any of the *IN indicators. A few tenacious indicators hung on until V5R1 when the last of the operation codes requiring them were replaced with BIFs.

Let's begin with the V4R2 BIFs. These new functions can replace most resulting indicators-that is, the HI, LO and EQ resulting indicators from the right-hand side of the C spec:

  • The %EOF function indicates an end of file condition on a sequential READ or a WRITE to a subfile.
  • %FOUND indicates whether the requested record was found on CHAIN, DELETE, SETGT or SETLL operations. It can also be used with SCAN, CHECK, CHECKR and LOOKUP.
  • %EQUAL is also set by the LOOKUP and SETLL operations when an exact match is found.
  • Rounding out the new I/O BIFs is %OPEN. When using user-controlled file opens, this provides a more straightforward and efficient way of testing whether a file is open, rather than the common technique of testing for error conditions when an I/O operation fails.

Another new BIF, %ERROR, is used in conjunction with the E (error) operation code extender and replaces the Error resulting indicator. %ERROR is cleared whenever an operation that specifies the E extender is about to begin. If that operation results in an error condition, it is set on. The %Status function can be interrogated to determine the specific error that occurred.

Note that the E extender and %ERROR can only be used with operation codes that allow an Error indicator, including the TEST operation and standard I/O operations.

















Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.

comments powered by Disqus



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

New and Improved XML-INTO

Namespace support makes the opcode a viable option

Authenticating on the Web

The finer points of OpenRPGUI, Part 1

The Microphone is Open

Add your voice: Should IBM i include open-source RPG tools?

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters