|
Not a problem!
A dilemma: The original poster asked a generic "timeout" question on the
MIDRANGE-L, which was non-specific as to the solution's language. No arrows,
therefore, for publishing an RPG solution here, please.
Although Scott Klement gets all the credit for this nifty technique, I will
add that it's *possible* I may have "dumbed-down" his code to get it to work
at V3R2; I can't remember for certain.
Display file TIMEOUTD:
A DSPSIZ(24 80 *DS3)
A R SCREEN1
A INVITE
A FRCDTA
A 9 17'There is a timeout on this-
A screen. Press ENTER'
A 10 27'or wait for it to time out.'
A MSG 50 O 14 16
RPG-IV program TIMEOUTR: (Note: RPG-III example follows)
fTimeOutD cf e Workstn UsrOpn
d RunCmd pr ExtPgm('QCMDEXC')
d Cmd 200a Const
d Len 15p 5 Const
d RcvDtaQ pr ExtPgm('QRCVDTAQ')
d dqname 10a Const
d dqLib 10a Const
d dqLen 5p 0
d dqData 80a
d dqWait 5p 0 Const
d DQLen s 5p 0
d TimeOut s 5p 0
d DQData s 80a
c* create a data queue in QTEMP.
c Callp RunCmd('CRTDTAQ DTAQ(QTEMP/TESTDQ) -
c MAXLEN(80) SEQ(*FIFO)': 200)
c* Make the display file use the new data queue
c Callp RunCmd('OVRDSPF FILE(TIMEOUTD) DTAQ(' +
c 'QTEMP/TESTDQ)': 200)
c* open the display file.
c Open TimeOutD
c* Show the screen the user. This format has the
c* "FRCDTA" keyword so the screen will show up immediately, and the
c* "INVITE" keyword so the keyboard isn't locked.
c Write Screen1
c* Wait for one of two conditions...
c* 1) an entry to appear on the data queue or
c* 2) A timeout while waiting for the data queue.
c Eval DQLen = 80
c Eval Timeout = 10
c Callp RcvDtaQ('TESTDQ':'QTEMP': DQLen: DQData:
c Timeout)
c* Show the results... (if Len=0, no data was received...)
c If dqLen = 0
c Eval Msg = 'TIMEOUT! Press ENTER to quit.'
c Else
c Read SCREEN1 9999
c Eval Msg = 'ENTER! Press ENTER again to quit'
c Endif
c Write SCREEN1
c* Wait "forever" for enter to be pressed, this time.
c* (Timeout=-1 means that it'll never timeout)
c Eval Timeout = -1
c Callp RcvDtaQ('TESTDQ':'QTEMP': DQLen: DQData:
c Timeout)
c Read SCREEN1 9999
c* Do some cleanup and end...
c Close TimeOutD
c Callp RunCmd('DLTOVR FILE(TIMEOUTD)':200)
c Callp RunCmd('DLTDTAQ DTAQ(QTEMP/TESTDQ)':200)
c Eval *inLR = *On
RPG-III program TIMEOUTR3:
FTIMEOUTDCF E WORKSTN UC
*
I 'CRTDTAQ DTAQ(QTEMP/- C $CRTDQ
I 'TESTDQ) MAXLEN(80) -
I ' SEQ(*FIFO)'
I 'OVRDSPF TIMEOUTD - C $OVRDF
I ' DTAQ(QTEMP/TESTDQ) -
I ' OVRSCOPE(*CALLLVL)'
I 'TIMEOUT! Press- C $TIMDO
I ' ENTER to quit.'
I 'ENTER! Press ENTER- C $NORML
I ' again to quit.'
I 'DLTOVR TIMEOUTD - C $DLTOV
I ' LVL(*)'
I 'DLTDTAQ - C $DLTDQ
I ' DTAQ(QTEMP/TESTDQ)'
*
* c* create a data queue in QTEMP.
C MOVE *BLANKS CMD
C CALL 'QCMDEXC'
C PARM $CRTDQ CMD 200
C PARM 200 CMDLEN 155
*
* c* Make the display file use the new data queue
C MOVE *BLANKS CMD
C CALL 'QCMDEXC'
C PARM $OVRDF CMD 200
C PARM 200 CMDLEN 155
*
* c* open the display file.
C OPEN TIMEOUTD
*
* c* Show the screen the user. This format has the
* c* "FRCDTA" keyword so the screen will show up immediately, and the
* c* "INVITE" keyword so the keyboard isn't locked.
C WRITESCREEN1
*
* c* Wait for one of two conditions...
* c* 1) an entry to appear on the data queue or
* c* 2) A timeout while waiting for the data queue.
C CALL 'QRCVDTAQ'
C PARM 'TESTDQ' DQNAME 10
C PARM 'QTEMP' DQLIB 10
C PARM 80 DQLEN 50
C PARM DQDATA 80
C PARM 10 DQWAIT 50
*
* c* Show the results... (if Len=0, no data was received...)
C DQLEN IFEQ *ZEROS
C MOVEL$TIMDO MSG
C ELSE
C READ SCREEN1 99
C MOVEL$NORML MSG
C ENDIF
C WRITESCREEN1
*
* c* Wait "forever" for enter to be pressed, this time.
* c* (Timeout=-1 means that it'll never timeout)
C CALL 'QRCVDTAQ'
C PARM 'TESTDQ' DQNAME 10
C PARM 'QTEMP' DQLIB 10
C PARM 80 DQLEN 50
C PARM DQDATA 80
C PARM -1 DQWAIT 50
C READ SCREEN1 99
*
* c* Do some cleanup and end...
C CLOSETIMEOUTD
C MOVE *BLANKS CMD
C CALL 'QCMDEXC'
C PARM $DLTOV CMD 200
C PARM 200 CMDLEN 155
C MOVE *BLANKS CMD
C CALL 'QCMDEXC'
C PARM $DLTDQ CMD 200
C PARM 200 CMDLEN 155
*
C SETON LR
- Dan
Dan Bale says "BAN DALE!"
IT - AS/400
Handleman Company
248-362-4400 Ext. 4952
D.Bale@Handleman.com
Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)
-------------------------- Original Message --------------------------
Well, if nothing else, it'd save me from having to post a reply :)
On Fri, 25 May 2001 D.BALE@handleman.com wrote:
> Scott Klement gave me a wonderful example of controlling a timeout at the
> record level utilizing the DDS keywords INVITE & FRCDTA and setting a
> temporary data queue in the program. Much more flexible. I have the source
> examples Scott provided, and I could post them here if anyone wants, the
> example source is not that lengthy. Just say the word.
>
> - Dale
> Dale Bale says "BAN DAN!"
> IT - AS/400
> Handleman Company
> 248-362-4400 Ext. 4952
> D.Bale@Handleman.com
> Quiquid latine dictum sit altum viditur.
> (Whatever is said in Latin seems profound.)
>
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.