Tips and Techniques: Eliminate Function Key Response Indicators

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

For years, I've been advocating the elimination of the function key response indicators. If you look at a typical display file, you might see something similar to the code shown below.

Note the response indicators assigned to the various function keys. As you know, when the function key is pressed, the corresponding indicator is turned on.










A                                      DSPSIZ(24 80 *DS3)
A                                      INDARA
A                                      CA03(03 'Exit')
A                                      CF04(04 'Search')
A                                      CF05(05 'Refresh')
A                                      CA12(12 'Cancel')

There is no reason to use the response indicators. This display file could have been specified as follows:

A                                      DSPSIZ(24 80 *DS3)
A                                      INDARA
A                                      CA03
A                                      CF04
A                                      CF05
A                                      CA12

Of course, by avoiding the use of the response indicators, the *INxx indicators are not set on. So that gives us two choices: We can use the cryptic *INKx indicators, or we can use the attention identification byte in position 369 of the workstation data structure (WSDS).

Using the *INKx indicators is one of the worst things you can do in RPG IV, so we won't bother with that technique. So that leaves the WSDS technique. To use this option, you code the following in your RPG IV program:

FEDITCUST  CF   E             WORKSTN infds(WSDS)

D WSDS            DS
D  FKey                          1A   Overlay(WSDS:369)

Then, in the Calculation specifications, you would code something similar to the following:

C                   SELECT
C                   When      fKey = F3
C                   if        CleanUp() = b_OK
C                   Return
C                   endif
C                   When      fKey = F5
C                   callp     Refresh()
C                   When      fKey = F11
C                   callp     ToggleDsp()
C                   endSL

The FKEY subfield of the WSDS references the named constants in a source member named FKEYS. It contains named constants that represent the hexadecimal value for each function key. To see a copy of the FKEY /COPY member, go here and click on the FKEYS source member.

Stop using response indicators and start using the attention identification byte. Things will be much easier for you in the future.

Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Language has been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG World conference for RPG programmers.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$