Function Keys

Function Keys Defined

Function indicators are available in a program that contains a WORKSTN device if the associated function keys are specified in data description specifications (DDS). Function keys are specified in DDS with the CFxx or CAxx keyword. The function key indicators correspond to function keys 1 through 24. Function key indicator KA corresponds to function key 1 (F1), KB to function key 2 (F2), etc., to KY representing function key 24 (F24). Function key indicators that are set on can then be used to condition calculation or output operations. Function key indicators can be set off by the RPG SETOFF operation code.

     A********************************************************************
     A*  DISPLAY NAME - SC0190DF                                         *
     A*                                                                  *
     A*  FUNCTION    - This display WORKS WITH softcode users            *
     A*                                                                  *
     A*  PROGRAMMER   - STEVE CROY            10/18/06                   *
     A********************************************************************
     A********************************************************************
     A*                   MODIFICATION LOG                               *
     A*                                                                  *
     A*   DATE   PROGRAMMER      DESCRIPTION                             *
     A*                                                                  *
     A********************************************************************
     A* Include PRINT and INVITE at the file level to allow  PRINT
     A* function and device file time out coding in applications
     A*
     A*%%EC
     A                                      DSPSIZ(24 80 *DS3)
     A                                      REF(*LIBL/SCUSRSPF)
     A                                      PRINT
     A                                      INDARA
     A                                      CF01
     A                                      CF02
     A                                      CA03
     A                                      CF04
     A                                      CF05
     A                                      CF06
     A                                      CF07
     A                                      CF08
     A                                      CF09
     A                                      CF10
     A                                      CF11
     A                                      CF12
     A                                      CF13
     A                                      CF14
     A                                      CF15
     A                                      CF16
     A                                      CF17
     A                                      CF18
     A                                      CF19
     A                                      CF20
     A                                      CF21
     A                                      CF22
     A                                      CF23
     A                                      CF24
     A                                      ROLLUP(90)
     A                                      ROLLDOWN(91)
     A                                      HOME
     A                                      HELP
     A          R SC019001
     A*%%TS  SD  20100330  145939  SCROY       REL-V5R4M0  5722-WDS
     A                                      BLINK
     A                                      OVERLAY
     A            JOBNAM        10A  O  1  2COLOR(BLU)
     A            PRGNAM        10A  O  1 13COLOR(BLU)
     A                                  1 27'iSoftwerks Incorporated'
     A                                  1 61SYSNAME
     A                                      COLOR(BLU)
     A                                  1 70DATE
     A                                      EDTCDE(Y)
     A                                      COLOR(BLU)
     A            USER          10A  O  2  2COLOR(BLU)
     A            JOBNBR         6A  O  2 13COLOR(BLU)
     A            Z$SEQ1        30A  O  2 24DSPATR(HI)
     A            FMTNAM         8A  O  2 61COLOR(BLU)
     A                                  2 70TIME
     A                                      COLOR(BLU)
     A                                  4  4'Type in option, press enter.'
     A                                      DSPATR(HI)
     A                                      COLOR(BLU)
     A                                  4 48'Position to:'
     A            Z$SCAN        10A  B  4 61CHANGE(22)
     A                                      DSPATR(HI)
     A            Z$OPT1        60A  O  5 12COLOR(BLU)
     A            Z$OPT2        60A  O  6 12COLOR(BLU)
     A                                  8  2'Op User       Status    Eff Date E-
     A                                      xp Date              Email         -
     A                                              '
     A                                      DSPATR(HI)
     A          R SC0190S1                  SFL
     A  58                                  SFLNXTCHG
     A            Z$RRN1         4S 0H
     A            Z$DBRN         9S 0H
     A            Z$OPT          2A  B  9  2DSPATR(HI)
     A  30                                  DSPATR(PR)
     A            MSUSRP    R        O  9  5REFFLD(MSUSRP)
     A            Z$STAT         9A  O  9 16
     A            Z$EFDT         6Y 0O  9 26EDTCDE(Y)
     A            Z$XDTE         6Y 0O  9 35EDTCDE(Y)
     A            Z$MAIL        35   O  9 44
     A          R SC0190C1                  SFLCTL(SC0190S1)
     A                                      SFLSIZ(0013)
     A                                      SFLPAG(0012)
     A                                      BLINK
     A                                      OVERLAY
     A  51                                  SFLDSP
     A  50                                  SFLDSPCTL
     A  53                                  SFLINZ
     A  55                                  SFLDLT
     A  52                                  SFLCLR
     A  54                                  SFLEND(*MORE)
     A                                      CSRLOC(#ROW       #COL)
     A            #ROW           3S 0H
     A            #COL           3S 0H
     A            Z$RRN2         4S 0H      SFLRCDNBR(CURSOR)
     A            Z$KEY1        60   O 22 11COLOR(BLU)
     A            Z$KEY2        60   O 23 11COLOR(BLU)
     A*----------------------------------------------------------------
     A* SUBFILE MESSAGE QUEUE
     A*----------------------------------------------------------------
     A          R SC0190S2                  SFL
     A                                      SFLMSGRCD(24)
     A            MSGKEY                    SFLMSGKEY
     A            PRGNAM                    SFLPGMQ
     A          R SC0190C2                  SFLCTL(SC0190S2)
     A                                      SFLSIZ(2) SFLPAG(1)
     A  59                                  SFLEND
     A  59                                  SFLDSP
     A                                      SFLDSPCTL
     A N59                                  SFLCLR
     A  59                                  SFLINZ
     A            PRGNAM                    SFLPGMQ


The example above defines all of the function keys at the file level. This might seem odd at first glance, since none of the keys is assigned to an indicator. That is because you can create a service that defines the bit-pattern of the function key. The workstation file I/O feedback data provides the last function key pressed. Byte 369 of the INFDS will contain the last function key pressed. Map the INFDS and then compare the key pressed to the value of the functions defined--no need for an indicator to determine which function key was

     A****************************************************************
     A* PHYSICAL FILE- SCKEYSPF                                      *
     A*                                                              *
     A* FUNCTION     - This file provides a set of 1 byte fields to  *
     A*                be used to define command function keys.      *
     A*                The file is used as an externally defined     *
     A*                data structure.                               *
     A*                                                              *
     A* PROGRAMMER   - Steve Croy        08/14/09                    *
     A****************************************************************
     A****************************************************************
     A*               FILE ATTRIBUTE SECTION                         *
     A*                                                              *
     A*  KEY FIELDS: *NONE                                           *
     A*  MAXMBRS   : 1                                               *
     A*                                                              *
     A****************************************************************

     A          R RSCKEYS
     A            ENTER          1          COLHDG('ENTER KEY')
     A            ROLLUP         1          COLHDG('ROLL UP KEY')
     A            ROLLDN         1          COLHDG('ROLL DOWN KEY')
     A            HELP           1          COLHDG('HELP KEY')
     A            PRINT          1          COLHDG('PRINT KEY')
     A            BSPACE         1          COLHDG('BACK SPACE')
     A            CLEAR          1          COLHDG('CLEAR KEY')
     A            F1             1          COLHDG('F1 KEY')
     A            F2             1          COLHDG('F2 KEY')
     A            F3             1          COLHDG('F3 KEY')
     A            F4             1          COLHDG('F4 KEY')
     A            F5             1          COLHDG('F5 KEY')
     A            F6             1          COLHDG('F6 KEY')
     A            F7             1          COLHDG('F7 KEY')
     A            F8             1          COLHDG('F8 KEY')
     A            F9             1          COLHDG('F9 KEY')
     A            F10            1          COLHDG('F10 KEY')
     A            F11            1          COLHDG('F11 KEY')
     A            F12            1          COLHDG('F12 KEY')
     A            F13            1          COLHDG('F13 KEY')
     A            F14            1          COLHDG('F14 KEY')
     A            F15            1          COLHDG('F15 KEY')
     A            F16            1          COLHDG('F16 KEY')
     A            F17            1          COLHDG('F17 KEY')
     A            F18            1          COLHDG('F18 KEY')
     A            F19            1          COLHDG('F19 KEY')
     A            F20            1          COLHDG('F20 KEY')
     A            F21            1          COLHDG('F21 KEY')
     A            F22            1          COLHDG('F22 KEY')
     A            F23            1          COLHDG('F23 KEY')
     A            F24            1          COLHDG('F24 KEY')
               

The physical file above was created as a map of the function keys. It is used as an externally defined data structure. (See the code snippett.) The file below was created as a map for the INFDS assging to a display file. There is a one byte field (the AID byte) defined as KEYPRESSED. This field is populated with I/O feedback that includes the last function key detected.


      ********************************************************************
      * File Name    - SCDSPFPF                                          *
      *                                                                  *
      * Function     - This file was designed to serve as an external    *
      *                data structure to define the file information     *
      *                data structure for display files.                 *
      ********************************************************************
     A          R RSCDSPF                   TEXT('DSPF INFDS')
     A            FILNAM         8          COLHDG('FILE' 'NAME')
     A            DSPOPN         1          COLHDG('FILE' 'OPEN')
     A            DSPEND         1          COLHDG('FILE' 'END')
     A            DSPSTS         5S 0       COLHDG('FILE' 'STS')
     A            DSCODE         6          COLHDG('RPG' 'OPCODE')
     A            DSRRTN         8          COLHDG('RPG' 'ROUTINE')
     A            DSRSTM         8          COLHDG('RPG' 'STATMNT')
     A            FMTNAM         8          COLHDG('FORMAT' 'NAME')
     A            DSPMSG         7          COLHDG('CPF' 'MSG')
     A            DSPINS         4          COLHDG('PGM' 'INSTR')
     A            DSUN01        10          COLHDG('UNDEFINED')
     A            DSPSIZ         4S 0       COLHDG('DSP' 'SIZE')
     A            DSPINP         2S 0       COLHDG('INPUT')
     A            DSPOUT         2S 0       COLHDG('OUTPUT')
     A            DSPMOD         2S 0       COLHDG('MODE')
     A            DSUN02         4          COLHDG('UNDEFINED')
     A            DSPODP         2S 0       COLHDG('ODP' 'TYPE')
     A            DSXNAM        10          COLHDG('XT' 'NAME')
     A            DSPLIB        10          COLHDG('FILE' 'LIB')
     A            DSSPLF        10          COLHDG('SPLF' 'NAME')
     A            DSSPLB        10          COLHDG('SPLF' 'LIB')
     A            DSSPL#         4B 0       COLHDG('SPLF' 'NBR')
     A            DSPLEN         4B 0       COLHDG('RECORD' 'LENGTH')
     A            DSUN03         2          COLHDG('UNDEFINED')
     A            DSPMBR        10          COLHDG('FILE' 'MEMBER')
     A            DSUN04         8          COLHDG('UNDEFINED 01')
     A            DSPTYP         4B 0       COLHDG('FILE' 'SUBTYPE')
     A            DSUN05         3          COLHDG('UNDEFINED 01')
     A            DSPLIN         4B 0       COLHDG('NBR OF' 'LINES')
     A            DSPCOL         4B 0       COLHDG('COLUMNS' 'DSP')
     A            DSPRCD         8B 0       COLHDG('RECORD' 'COUNT')
     A            DSPACC         2          COLHDG('ACCESS' 'TYPE')
     A            DSPDUP         1          COLHDG('ALLOW' 'DUPE')
     A            DSPSRC         1          COLHDG('SOURCE' 'FILE')
     A            DSUFCB        10          COLHDG('USER' 'FC' 'BLK')
     A            DSFBOV        10          COLHDG('FC' 'BLK' 'OVR')
     A            DSVLID         4B 0       COLHDG('VOL' 'ID' 'OVR')
     A            DSBKIO         4B 0       COLHDG('BLK' 'IO')
     A            DSPOFL         4B 0       COLHDG('OVERFLOW' 'LINE')
     A            DSBKOO         4B 0       COLHDG('BLK' 'IO' 'OFL')
     A            DSUN06         5          COLHDG('UNDEFINED')
     A            DSPDEV        10          COLHDG('PROGRAM' 'DEVICE')
     A            DSFBST         4B 0       COLHDG('FC' 'BLK' 'STS')
     A            DSUN07         2          COLHDG('UNDEFINED')
     A            DSPOST         4B 0       COLHDG('DB' 'OPN' 'STS')
     A            DSFLAG         1          COLHDG('FILE' 'FLAG')
     A            DSOPID         2          COLHDG('OPEN' 'ID')
     A            DSMAXR         4B 0       COLHDG('MAX' 'RECORDS')
     A            DSUN08       151          COLHDG('UNDEFINED')
     A            KEYPRESSED     1          COLHDG('FUNCTION' 'KEY')
     A            ROW            1          COLHDG('CURSOR' 'ROW')
     A            COL            1          COLHDG('CURSOR' 'COL')
     A            DSUN09         6          COLHDG('UNDEFINED')
     A            SFRRN#         4B 0       COLHDG('SFL' 'RRN')