PGM DCLF FILE(QGPL/MENU) START: SNDRCVF DEV(*FILE) RCDFMT(MENUFMT) WAIT(*NO) WAIT MONMSG MSGID(CPF0889) EXEC(SIGNOFF) CHGVAR VAR(&IN99) VALUE('0') IF COND(&IN01) THEN(GOTO CMDLBL(START)) OPTION1: /* OPTION 1-ORDER ENTRY */ IF COND(&OPTION *EQ '1') THEN(DO) CALL PGM(ORDENT) GOTO CMDLBL(START) ENDDO OPTION2: /* OPTION 2-ORDER DISPLAY */ IF COND(&OPTION *EQ '2') THEN(DO) CALL PGM(ORDDSP) GOTO CMDLBL(START) ENDDO OPTION3: /* OPTION 3-ORDER CHANGE */ IF COND(&OPTION *EQ '3') THEN(DO) CALL PGM(ORDCHG) GOTO CMDLBL(START) ENDDO OPTION4: /* OPTION 4-ORDER PRINT */ IF COND(&OPTION *EQ '4') THEN(DO) CALL PGM(ORDPRT) GOTO CMDLBL(START) ENDDO OPTION9: /* OPTION 9-SIGNOFF */ IF COND(&OPTION *EQ '9') THEN(SIGNOFF) OPTIONERR: /* OPTION SELECTED NOT VALID */ CHGVAR VAR(&IN99) VALUE('1') GOTO CMDLBL(START) ENDPGM
This program illustrates how to write a CL program using a display file that will wait for a specified amount of time for the user to enter an option. If he does not, the user is signed off.
The display file was created with the following command:
CRTDSPF FILE(MENU) SRCFILE(QGPL/QDDSSRC) SRCMBR(MENU) + DEV(*REQUESTER) WAITRCD(60)
The display file will use the *REQUESTER device. When a WAIT command is issued, it waits for the number of seconds (60) specified on the WAITRCD keyword. The following is the DDS for the display file:
SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ... ... 8 0100 A PRINT CA01(01) 0200 A R MENUFMT BLINK 0300 A TEXT('Order Entry Menu') 0400 A 1 31'Order Entry Menu' 0500 A 2 2'Select one of the following: ' 0600 A 3 4'1. Enter Order' 0700 A 4 4'2. Display Order' 0800 A 5 4'3. Change Order' 0900 A 6 4'4. Print Order' 1000 A 7 4'9. Sign Off' 1100 A 23 2'Option:' 1200 A OPTION 1 I 23 10 1300 A 99 ERRMSG('Invalid option selected.') * * * * * * E N D O F S O U R C E * * * * *
The program performs a SNDRCVF WAIT(*NO) to display the menu and request an option from the user. Then it issues a WAIT command to accept an option from the user. If the user enters a 1 through 4, the appropriate program is called. If the user enters a 9, the SIGNOFF command is issued. If the user enters an option that is not valid, the menu is displayed with an 'OPTION SELECTED NOT VALID' message. The user can then enter another valid option. If the user does not respond within 60 seconds, the CPF0889 message is issued to the program and the MONMSG command issues the SIGNOFF command.
A SNDF command using a record format containing the INVITE DDS keyword could be used instead of the SNDRCVF WAIT(*NO). The function would be the same.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.