Use function keys without response indicators

Cut down on the number of indicators used in your program.

A lot of programmers standardize on indicator usage for function keys within display file programs, e.g. *IN01 for F1, *IN03 for F3, etc, which is fine and readable if you are aware of the convention being used.

However, if you want to cut down on the number of indicators used in your program and make it easier to read and maintain then you should code your display files not to use response indicators and make use of the device dependent I/O feedback area of the File Information Data Structure instead.

Position 369 of the File Information Data Structure for display files contains a hex byte that represents the function key (or other grey key) pressed by the user.

By coding field @FNKEY in this position of the INFDS and then defining text constants for the appropriate function key value, I can test for the use of function keys within my programs by using:

 

                 @FNKEY     IFEQ $F5
                            ...
                            ...
                            ENDIF

as opposed to:

                 *IN05      IFEQ *ON
                            ...
                            ...
                            ENDIF 

The source snippets below show the coding needed within your RPG/400 program to use this technique.


 RPG SOURCE SNIPPET
==================

     FWORKSTN CF  E                    WORKSTN      KINFDS INFDS
     F*   Display File
     F*----------------------------------------------------------------
     IINFDS       DS
     I                                      369 369 @FNKEY
     I* Function key values
     I              X'31'                 C         $F1
     I              X'32'                 C         $F2
     I              X'33'                 C         $F3
     I              X'34'                 C         $F4
     I              X'35'                 C         $F5
     I              X'36'                 C         $F6
     I              X'37'                 C         $F7
     I              X'38'                 C         $F8
     I              X'39'                 C         $F9
     I              X'3A'                 C         $F10
     I              X'3B'                 C         $F11
     I              X'3C'                 C         $F12
     I              X'B1'                 C         $F13
     I              X'B2'                 C         $F14
     I              X'B3'                 C         $F15
     I              X'B4'                 C         $F16
     I              X'B5'                 C         $F17
     I              X'B6'                 C         $F18
     I              X'B7'                 C         $F19
     I              X'B8'                 C         $F20
     I              X'B9'                 C         $F21
     I              X'BA'                 C         $F22
     I              X'BB'                 C         $F23
     I              X'BC'                 C         $F24
     I              X'BD'                 C         $CLEAR
     I              X'F1'                 C         $ENTER
     I              X'F3'                 C         $HELP
     I              X'F4'                 C         $RLLDN
     I              X'F5'                 C         $RLLUP
     I              X'F4'                 C         $PAGUP
     I              X'F5'                 C         $PAGDN
     I              X'F6'                 C         $PRINT
     I              X'F8'                 C         $BCKSP
     I              X'3F'                 C         $AUTO
     I*----------------------------------------------------------------
     C                     ...
     C                     ...
     C                     EXFMTxxxxxxxx
     C*
     C* Process function keys...
     C*
     C                     SELEC
     C           @FNKEY    WHEQ $F1
     C                     EXSR HELP
     C           @FNKEY    WHEQ $F3
     C                      ..
     C                     ...
     C           @FNKEY    WHEQ $ENTER
     C                     ...
     C                     ENDSL
     C*----------------------------------------------------------------

DDS SOURCE SNIPPET
==================
     A          R DSPFMAT
     A                                      CF01
     A                                      CF03
     A                                      PAGEDOWN
     A                                      etc...

  
  

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was first published in June 2003

Dig deeper on iSeries CL programming

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchEnterpriseLinux

SearchDataCenter

Close