k10benmamar@yahoo.ca
04-19-2002, 08:31 AM
8.6.8 Sample Program 8-Read Operation with Time-Out The following figures illustrate the program examples for READ operation with time-out. __________________________________________________ ______________________ | Table 12. List of Figures for READ Operation with Time-Out | |__________________________ _____________________________________________| | Figure | Contents | |__________________________|______________________ _______________________| | Figure 107 below | DDS for display device file | |__________________________|______________________ _______________________| | Figure 109 | File description, input, and calculation | | | specifications | |__________________________|______________________ _______________________| *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..* A************************************************* ******************* A* FILE NAME : HOTELDSP * A* DESCRIPTION: DISPLAY FILE FOR TIME OUT EXAMPLE * A************************************************* ******************* AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++ ++++++++++++++++++* A INVITE A R REQUEST A OVERLAY A ROOM 5A I 10 46DSPATR(HI) A 10 26'Enter Room Number:' A DSPATR(HI) Figure 107. DDS Read Operation with Time-Out __________________________________________________ ________________________________ | | | | | | | | | | | | | Enter Room Number: 10025 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |_________________________________________________ _________________________________| Figure 108. Sample Screen for Time-out Figure 109 shows an example of file description, input, and calculation specifications for READ operation with time-out. *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..* F************************************************* ******************* F* PROGRAM ID - TIMEOUT * F* PROGRAM NAME - TIME OUT ON READ * F************************************************* ******************* FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KEx it++Entry+A....U1.* FHOTELDSPCF E WORKSTN F KNUM 1 F KINFDS FEEDBK IDsname....NODsExt-file++.............OccrLen+......................* IFEEDBK DS I..............Ext-field+............PFromTo++DField+...............* I *STATUS STATUS CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHi LoEqComments++++++* C WRITEREQUEST C READ HOTELDSP 9950 C EXSR ERRCHK C MOVE '1' *INLR C************************************************* ******************* C* SUBROUTINE - ERRCHK * C* PURPOSE - CHECK STATUS FOR MAX WAIT * C************************************************* ******************* C ERRCHK BEGSR C STATUS IFEQ 1331 C MOVE 'SIGNOFF' CMD 7 C Z-ADD7 LEN 155 C CALL 'QCMDEXC' C PARM CMD C PARM LEN C END C ENDSR Figure 109. File Description, Input, and Calculation Specifications for Read Operation with Time-Out This program causes the work station to be signed off, when no workstation activity has occurred during a specified length of time. ° In the DDS for the display file HOTELDSP, the keyword INVITE is specified for all formats. You specify a length of time to wait with the WAITRCD parameter on the CRTDSPF (or CHGDSPF) command to create (or change) this file. ° In the file specifications, the file HOTELDSP is specified as a WORKSTN file with the option NUM. RPG treats the file as a multiple-device file. ° In the input specifications, the *STATUS subfield of the file information data structure is named STATUS. ° The WRITE operation puts format REQUEST on the work station and, because of the keyword INVITE, makes the work station an invited device. ° The READ-by-file-name operation to the file HOTELDSP waits for the length of time specified on the WAITRCD parameter for a response from the invited device. ° If no response comes in time, error indicator 99 is set on and the program continues with the next operation. ° The next operation performs the ERRCHK subroutine. This subroutine checks the STATUS subfield of the file information data structure. Status code 1331 indicates the READ operation timed out, and the ERRCHK subroutine signs the work station off. Other status codes produce other results. Note: This example is not a complete program. --------------------------------------------------------------------------------