Time counting in reverse order
C eval endtime=endtime1+%seconds(30)
C endtime subdur 1:*seconds remtime
C dow *in03 = *off
C write(e) autoscreen
C read(e) autodsp2
C remtime subdur 1:*seconds remtime
C move remtime time1
C enddo
Last Wiki Answer Submitted: December 26, 2011 3:20 pm by WoodEngineer5,525 pts.
All Answer Wiki Contributors: WoodEngineer5,525 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
The IBM i comes with a comprehensive array of clocks and timers and wait mechanisms.
Given that any ILE language can use components from any other, why are you stating RPG?
As Phil mentioned, an outline of what you intend to do would be helpful. For instance do you want to wait 30 seconds period, or wait up to 30 seconds with an input from the operator being allowed to get into the processing faster. Do you want to do processing during the 30 second interval or just idle? Knowing the answers to these questions would allow us to help you more.
And as a minor aside, if you use ‘sleep’ (as shown in an earlier example) you don’t need to specify the QC2LE binding directory if your development system is at 6.1 or higher.
i haven’t tried yet, but i just need the idea how to do it,
i would like to make a project for online test, where i have to implement a condition to a student , who should answer the question in 30 sec, after 30sec it should go to the next question?
Your plan will require special attention to the display.
Typically the RPG program passes control the the display file and waits for the user to press a function key or enter to return.
So you’ll need some advice from the Screen geeks before you start your design.
Screen Geeks – how can an as/400 display file
1. display a queston
2. display the remaining time – value updated every second in RPG
3. receive a user input
4. This is probably covered in 2 – get back to the program when time runs out?
Phil
Here is sample code and dds of a program I use to prompt user for an answer and after 20 second delay of no input it executes a call or other process.
FDsp000d1 cf e workstn infds(infds)
F Maxdev(*file)
Dinfds ds
D status *status
D cfkey 369 369
D
Dexit C const(X’33′)
Dcancel C const(X’3C’)
Dprompt C const(X’34′)
Denter C const(X’F1′)
*
*****************************************************************
* Main Routine
*****************************************************************
*
C dou (cfkey = exit) or (cfkey = cancel)
*
C write screen1
C read dsp000d1 99lr
C if *in99 = *on and status=1331
C call your program or process
C endif
C if *in01 = *on
C call ‘HELP’
C parm ‘SCREEN1′ Screen 10
C parm 9 crow 15 5
C parm 35 ccol 15 5
C parm return 2
C endif
*
C enddo
*
C eval *inlr = *on
*
Display specs
A*
A* CRTDSPF FILE(XXX/DSP000D1) SRCFILE(XXX/QDDSSRC) +
A* MBR(DSP000D1) WAITRCD(20) <=== DELAY SECONDS(1-32767)
A*
A*%%EC
A DSPSIZ(24 80 *DS3)
A CA01(01 ‘HELP’)
A CA03(03 ‘EXIT’)
A INVITE
A*
A R SCREEN1
A 1 19′TEST WAITRCD PARAMETER’
A DSPATR(HI)
A DSPATR(UL)
A 9 28′INPUT:’
A INPUT 1A B 9 35
A 22 7′F3=Exit’
A COLOR(BLU)
If you’re planning to program you need to learn how to track down problems and solve them!
Someone was nice enough to share a chunk of code with you — you fix it and share the solution with the rest of us!
You got an error message during compile? Investigate the compile listing, it will tell you the line of the error. Apparently you need to check the types of the variables on that line. Make some effort, please.
A DSPSIZ(24 80 *DS3)
A INVITE
A R SCREEN1
A CA03(03 ‘exit’)
A CF01(01 ‘help’)
A 1 19′TEST WAITRCD PARAMETER’
A DSPATR(HI)
A DSPATR(UL)
A 9 28′INPUT:’
A INPUT 1A B 9 35
A 22 7′F3=EXIT’
A COLOR(BLU)
rpgle coding..
Fautodsp1 cf e workstn infds(infds)
F Maxdev(*file)
Dinfds ds
dstatus 11 15
dcfkey 369 369
Dexit c const(X’33′)
Dcancel c const(X’3C’)
Dprompt c const(X’34′)
Denter c const(X’F1′)
C dou ((cfkey = exit) or (cfkey = cancel))
C write screen1
C read autodsp1 99lr
C if ((*in99 = *on) and (status=1331))
* call your program or process
C endif
C if (*in01 = *on)
C call ‘HELP’
C parm ‘SCREEN’ screen 10
C parm 9 crow 15 5
C parm 35 ccol 15 5
C parm return 2
C endif
C enddo
C eval *inlr = *on
i getting this error.. *RNF7421 30 17 000804 Operands are not compatible with the type of operator.
Sure, you provided better info, but apparently you’ve moved on from this point based on your later thread
The error detected during compiling is on line 804 .. which would help if you had posted line numbers or you could have used to find the error. I suspect that it’s
status=1331 since you declared status as alpha in the d-spec dstatus 11 15
and try to compare it with a numeric. The code you used as a model defined status as type *STATUS
*STATUS is 11 15 Zoned decimal 5,0 *STATUS Status code. http://publib.boulder.ibm.com/iseries/v5r1/ic2924/books/c092508378.htm#HDRFLFEED
Change the definition of status to 11 15 S 0 or as *STATUS
You don’t need the F1 code for my example. It was some extra code I mistakenly copied and is only used for help not used for your example. I was just showing how I use a 20 second response time. You can modify it however you like.
Give a code such that in a clock second hand work as minute hand, minute hand work as a hour hand and hour hand work as a second hand…. code should be in c language……..
Why? That is, can you provide a business reason why we should? This seems too much like an academic exercise rather than something needed for a useful work function.
If you need academic help, start by showing us the code that you have developed so far and explaining the obstacle that locks you from going farther.
Why don’t you give us an outline of how you plan to do this.
Show us the code you’ve got and we’ll help.
Phil
The IBM i comes with a comprehensive array of clocks and timers and wait mechanisms.
Given that any ILE language can use components from any other, why are you stating RPG?
As Phil mentioned, an outline of what you intend to do would be helpful. For instance do you want to wait 30 seconds period, or wait up to 30 seconds with an input from the operator being allowed to get into the processing faster. Do you want to do processing during the 30 second interval or just idle? Knowing the answers to these questions would allow us to help you more.
And as a minor aside, if you use ‘sleep’ (as shown in an earlier example) you don’t need to specify the QC2LE binding directory if your development system is at 6.1 or higher.
Bruce Vining
i want to count the time in reverse order.. for example one screen leave after 30 (like count down) seconds…. using RPG?
That’s reasonable. What problems are you having? What have you tried?
Tom
Hi guys.,
i haven’t tried yet, but i just need the idea how to do it,
i would like to make a project for online test, where i have to implement a condition to a student , who should answer the question in 30 sec, after 30sec it should go to the next question?
Your plan will require special attention to the display.
Typically the RPG program passes control the the display file and waits for the user to press a function key or enter to return.
So you’ll need some advice from the Screen geeks before you start your design.
Screen Geeks – how can an as/400 display file
1. display a queston
2. display the remaining time – value updated every second in RPG
3. receive a user input
4. This is probably covered in 2 – get back to the program when time runs out?
Phil
you will probably need to use some of the techniques Scott Klement wrote about in these articles:
•Automatically Refreshing Screens, Part 1
•Automatically Refreshing Screens, Part 2
Here is sample code and dds of a program I use to prompt user for an answer and after 20 second delay of no input it executes a call or other process.
FDsp000d1 cf e workstn infds(infds)
F Maxdev(*file)
Dinfds ds
D status *status
D cfkey 369 369
D
Dexit C const(X’33′)
Dcancel C const(X’3C’)
Dprompt C const(X’34′)
Denter C const(X’F1′)
*
*****************************************************************
* Main Routine
*****************************************************************
*
C dou (cfkey = exit) or (cfkey = cancel)
*
C write screen1
C read dsp000d1 99lr
C if *in99 = *on and status=1331
C call your program or process
C endif
C if *in01 = *on
C call ‘HELP’
C parm ‘SCREEN1′ Screen 10
C parm 9 crow 15 5
C parm 35 ccol 15 5
C parm return 2
C endif
*
C enddo
*
C eval *inlr = *on
*
Display specs
A*
A* CRTDSPF FILE(XXX/DSP000D1) SRCFILE(XXX/QDDSSRC) +
A* MBR(DSP000D1) WAITRCD(20) <=== DELAY SECONDS(1-32767)
A*
A*%%EC
A DSPSIZ(24 80 *DS3)
A CA01(01 ‘HELP’)
A CA03(03 ‘EXIT’)
A INVITE
A*
A R SCREEN1
A 1 19′TEST WAITRCD PARAMETER’
A DSPATR(HI)
A DSPATR(UL)
A 9 28′INPUT:’
A INPUT 1A B 9 35
A 22 7′F3=Exit’
A COLOR(BLU)
Mr. Steve Winfrey, i tried your tips, but i didn’t get the answer…..
i got the error — Operands are not compatible with the type of operator.
if u have anther solution, share me…..
If you’re planning to program you need to learn how to track down problems and solve them!
Someone was nice enough to share a chunk of code with you — you fix it and share the solution with the rest of us!
You got an error message during compile? Investigate the compile listing, it will tell you the line of the error. Apparently you need to check the types of the variables on that line. Make some effort, please.
Mr. Phil, i show my program… check it plz…
display file coding..
A DSPSIZ(24 80 *DS3)
A INVITE
A R SCREEN1
A CA03(03 ‘exit’)
A CF01(01 ‘help’)
A 1 19′TEST WAITRCD PARAMETER’
A DSPATR(HI)
A DSPATR(UL)
A 9 28′INPUT:’
A INPUT 1A B 9 35
A 22 7′F3=EXIT’
A COLOR(BLU)
rpgle coding..
Fautodsp1 cf e workstn infds(infds)
F Maxdev(*file)
Dinfds ds
dstatus 11 15
dcfkey 369 369
Dexit c const(X’33′)
Dcancel c const(X’3C’)
Dprompt c const(X’34′)
Denter c const(X’F1′)
C dou ((cfkey = exit) or (cfkey = cancel))
C write screen1
C read autodsp1 99lr
C if ((*in99 = *on) and (status=1331))
* call your program or process
C endif
C if (*in01 = *on)
C call ‘HELP’
C parm ‘SCREEN’ screen 10
C parm 9 crow 15 5
C parm 35 ccol 15 5
C parm return 2
C endif
C enddo
C eval *inlr = *on
i getting this error.. *RNF7421 30 17 000804 Operands are not compatible with the type of operator.
Sure, you provided better info, but apparently you’ve moved on from this point based on your later thread
The error detected during compiling is on line 804 .. which would help if you had posted line numbers or you could have used to find the error. I suspect that it’s
status=1331 since you declared status as alpha in the d-spec dstatus 11 15
and try to compare it with a numeric. The code you used as a model defined status as type *STATUS
*STATUS is 11 15 Zoned decimal 5,0 *STATUS Status code.
http://publib.boulder.ibm.com/iseries/v5r1/ic2924/books/c092508378.htm#HDRFLFEED
Change the definition of status to 11 15 S 0 or as *STATUS
Phil
i can’t to declare like that
STATUS *STATUS
how to declare this statement in D – spec..
i solve this program problem….
when i press F1, i got this error – CPF4737 – wait time error… how to solve this problem..
You don’t need the F1 code for my example. It was some extra code I mistakenly copied and is only used for help not used for your example. I was just showing how I use a 20 second response time. You can modify it however you like.
Give a code such that in a clock second hand work as minute hand, minute hand work as a hour hand and hour hand work as a second hand…. code should be in c language……..
Give a code such that in a clock…
Why? That is, can you provide a business reason why we should? This seems too much like an academic exercise rather than something needed for a useful work function.
If you need academic help, start by showing us the code that you have developed so far and explaining the obstacle that locks you from going farther.
Tom