Time counting in reverse order

3790 pts.
Tags:
RPG Date Formatting
hi.. i want to count the time in reverse order.. for example one screen leave after 30 (like count down) seconds.... using RPG?

Software/Hardware used:
as400 v5r3

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 17  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb
    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
    49,970 pointsBadges:
    report
  • Yorkshireman
    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?
    5,580 pointsBadges:
    report
  • bvining
    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
    6,495 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • pdsathishkumar
    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?
    3,790 pointsBadges:
    report
  • philpl1jb
    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
    49,970 pointsBadges:
    report
  • BigKat
    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
    8,210 pointsBadges:
    report
  • filuphaze
    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)
    475 pointsBadges:
    report
  • pdsathishkumar
    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.....
    3,790 pointsBadges:
    report
  • philpl1jb
    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.
    49,970 pointsBadges:
    report
  • pdsathishkumar
    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.
    3,790 pointsBadges:
    report
  • philpl1jb
    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
    49,970 pointsBadges:
    report
  • pdsathishkumar
    i can't to declare like that STATUS *STATUS how to declare this statement in D - spec..
    3,790 pointsBadges:
    report
  • pdsathishkumar
    i solve this program problem.... when i press F1, i got this error - CPF4737 - wait time error... how to solve this problem..
    3,790 pointsBadges:
    report
  • filuphaze
    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.
    475 pointsBadges:
    report
  • Amit005
    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........
    10 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following