Use function keys without response indicators

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

as opposed to:

                 *IN05      IFEQ *ON

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


     FWORKSTN CF  E                    WORKSTN      KINFDS INFDS
     F*   Display File
     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
     C                     ...
     C                     ...
     C                     EXFMTxxxxxxxx
     C* Process function keys...
     C                     SELEC
     C           @FNKEY    WHEQ $F1
     C                     EXSR HELP
     C           @FNKEY    WHEQ $F3
     C                      ..
     C                     ...
     C           @FNKEY    WHEQ $ENTER
     C                     ...
     C                     ENDSL

     A          R DSPFMAT
     A                                      CF01
     A                                      CF03
     A                                      PAGEDOWN
     A                                      etc...



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

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.