The SETKEY program follows: I* EXTERNAL D.S. CONTAINING THE COMMAND KEY NAMES. I* IKEYDS E DSSETKEYDS01 I* C* C*ENTRYPARAMETERS. C* C *ENTRY PLIST C* C PARM KEYDS C* C* SET ALL FIELDS TO HEX'00' C* C BITOF'01234567' ENTER C MOVELENTER ROLLUP C MOVELENTER ROLLDN C MOVELENTER HELP C MOVELENTER PRINT C MOVELENTER BSPACE C MOVELENTER CLEAR C MOVELENTER F1 C MOVELENTER F2 C MOVELENTER F3 C MOVELENTER F4 C MOVELENTER F5 C MOVELENTER F6 C MOVELENTER F7 C MOVELENTER F8 C MOVELENTER F9 C MOVELENTER F10 C MOVELENTER F11 C MOVELENTER F12 C MOVELENTER F13 C MOVELENTER F14 C MOVELENTER F15 C MOVELENTER F16 C MOVELENTER F17 C MOVELENTER F18 C MOVELENTER F19 C MOVELENTER F20 C MOVELENTER F21 C MOVELENTER F22 C MOVELENTER F23 C MOVELENTER F24 C* C* SET ON THE DESIRED BITS. C BITON'01237' ENTER C BITON'012357' ROLLUP C BITON'01235' ROLLDN C BITON'012367' HELP C BITON'012356' PRINT C BITON'01234' BSPACE C BITON'023457' CLEAR C BITON'237' F1 C BITON'236' F2 C BITON'2367' F3 C BITON'235' F4 C BITON'2357' F5 C BITON'2356' F6 C BITON'23567' F7 C BITON'234' F8 C BITON'2347' F9 C BITON'2346' F10 C BITON'23467' F11 C BITON'2345' F12 C BITON'0237' F13 C BITON'0236' F14 C BITON'02367' F15 C BITON'0235' F16 C BITON'02357' F17 C BITON'02356' F18 C BITON'023567' F19 C BITON'0234' F20 C BITON'02347' F21 C BITON'02346' F22 C BITON'023467' F23 C BITON'02345' F24 C* C MOVEL'1' *INLR
You must also create a file (I called it SETKEYDS01) that I referenced in the -I- spec as an external data structure. This file will contain each of the variables used in the SETKEY program (above). Define them as 1A variables.
Once you have created your external data structure (SETKEYDS01) and RPG program (SETKEY) you may use them in any program that uses a WORKSTN device.
In your program, define your -F- spec as follows:
FSCREENFMCF E WORKSTN KINFDS DSPFDS
The DSPFDS (File Information Data Structure) must then be referenced in the -I- specs:
IDSPFDS DS I* I 369 369 CMDKEY I*
Feedback position 369 contains a HEX value that represents the Function Key that was pressed. The SETKEY program establishes variables that will contain the same HEX value.
During your initial calcs, code the following statements:
C CALL 'SETKEY' C PARM KEYDS
Now, after any EXFMT statement, check for the key the user hit, as follows:
C CMDKEY IFEQ F2 C CMDKEY IFEQ F15 C CMDKEY IFEQ F21 C CMDKEY IFEQ HELP C CMDKEY IFEQ ENTER C CMDKEY IFEQ ROLLDN
I only included a few examples. You may use any of the variables from the SETKEY program. Doesn't this make it a lot easier to know what key the user pressed? I know that many of you use indicators 01 - 24. But what about the other keys like ROLLUP and HELP? (Especially the ENTER key.) Enjoy.