Problem solve Get help with specific problems with your technologies, process and projects.

Working with function keys

Instead of using indicators for trapping function keys in RPG, you can use real key equivalents such as F1, F12, F20, etc.

Instead of using indicators for trapping function keys in RPG, you can use real key equivalents such as F1, F12,...

F20, etc. You can find more handy utilities at my Web site.

The benefits of using this function:

a) More readable source -- you see what's meant.
b) You can keep the indicators for real signaling functions.
c) There's no need to program function key indicators in the display file.
d) There's no need to distinguish the ENTER key from FUNCTION KEYS.

In my opinion, indicators for function keys tend more to a 'who knows what's going on here?' - source, because indicators are also used for other things.

In the F-specs, define a display file with a continuation line for the buffer to hold the device description:

 
      FDEFAULT#CF  E                    WORKSTN
      F                                              KINFDS DEVICE
 
 In the I-specs, add the following:
 
      IDEVICE      DS
      I                                        1   8 ##SCRN
      I                                       38  45 ##RECF
      I                                      369 369 ##KEY
      I                                    B 370 3710##CURS
 
 then, right before your the C-specs begin, add the following code:
 
      I            DS                             31
      I                                        1   1 ENTER
      I                                        2   2 ROLLUP
      I                                        3   3 ROLLDN
      I                                        4   4 HELP
      I                                        5   5 PRINT
      I                                        6   6 BSPACE
      I                                        7   7 CLEAR
      I                                        8   8 F1
      I                                        9   9 F2
      I                                       10  10 F3
      I                                       11  11 F4
      I                                       12  12 F5
      I                                       13  13 F6
      I                                       14  14 F7
      I                                       15  15 F8
      I                                       16  16 F9
      I                                       17  17 F10
      I                                       18  18 F11
      I                                       19  19 F12
      I                                       20  20 F13
      I                                       21  21 F14
      I                                       22  22 F15
      I                                       23  23 F16
      I                                       24  24 F17
      I                                       25  25 F18
      I                                       26  26 F19
      I                                       27  27 F20
      I                                       28  28 F21
      I                                       29  29 F22
      I                                       30  30 F23
      I                                       31  31 F24
      Ç*
      * ---------------------------------------------------------------
     * Set values for KEY variables
      C                     BITOF'01234567'ENTER
      C                     BITOF'01234567'ROLLUP
      C                     BITOF'01234567'ROLLDN
      C                     BITOF'01234567'HELP
      C                     BITOF'01234567'PRINT
      C                     BITOF'01234567'BSPACE
      C                     BITOF'01234567'CLEAR
      C                     BITOF'01234567'F1
      C                     BITOF'01234567'F2
      C                     BITOF'01234567'F3
      C                     BITOF'01234567'F4
      C                     BITOF'01234567'F5
      C                     BITOF'01234567'F6
      C                     BITOF'01234567'F7
      C                     BITOF'01234567'F8
      C                     BITOF'01234567'F9
      C                     BITOF'01234567'F10
      C                     BITOF'01234567'F11
      C                     BITOF'01234567'F12
      C                     BITOF'01234567'F13
      C                     BITOF'01234567'F14
      C                     BITOF'01234567'F15
      C                     BITOF'01234567'F16
      C                     BITOF'01234567'F17
      C                     BITOF'01234567'F18
      C                     BITOF'01234567'F19
      C                     BITOF'01234567'F20
      C                     BITOF'01234567'F21
      C                     BITOF'01234567'F22
      C                     BITOF'01234567'F23
      C                     BITOF'01234567'F24
       *
      C                     BITON'01237'   ENTER            X'F1
      C                     BITON'012357'  ROLLUP           X'F5
      C                     BITON'01235'   ROLLDN           X'F4
      C                     BITON'012367'  HELP             X'F3
      C                     BITON'012356'  PRINT            X'F6
      C                     BITON'01234'   BSPACE           X'F8
      C                     BITON'023457'  CLEAR            X'BD
      C                     BITON'237'     F1               X'31
      C                     BITON'236'     F2               X'32
      C                     BITON'2367'    F3               X'33
      C                     BITON'235'     F4               X'34
      C                     BITON'2357'    F5               X'35
      C                     BITON'2356'    F6               X'36
      C                     BITON'23567'   F7               X'37
      C                     BITON'234'     F8               X'38
      C                     BITON'2347'    F9               X'39
      C                     BITON'2346'    F10              X'3A
      C                     BITON'23467'   F11              X'3B
      C                     BITON'2345'    F12              X'3C
      C                     BITON'0237'    F13              X'B1
      C                     BITON'0236'    F14              X'B2
      C                     BITON'02367'   F15              X'B3
      C                     BITON'0235'    F16              X'B4
      C                     BITON'02357'   F17              X'B5
      C                     BITON'02356'   F18              X'B6
      C                     BITON'023567'  F19              X'B7
      C                     BITON'0234'    F20              X'B8
      C                     BITON'02347'   F21              X'B9
      C                     BITON'02346'   F22              X'BA
      C                     BITON'023467'  F23              X'BB
      C                     BITON'02345'   F24              X'BC
 
 next, question which key was pressed like this:
 
      C                     SELEC
      C           ##KEY     WHEQ F4
      C                     EXSR SRF041
       *
      C           ##KEY     WHEQ F5
      C                     EXSR SRCLR1
      C                     EXSR SRLOD1
       *
      C           ##KEY     WHEQ F6
      C                     Z-ADDNEWREC    #RECN1
       *
      C           ##KEY     WHEQ F12
      C                     LEAVE
 
 etc.
 
 



Dig Deeper on iSeries programming commands

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close