Calibration page on startup then times out

Discussion in 'Pascal Logic Code Examples' started by Trevor, Mar 25, 2026.

  1. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    550
    Likes Received:
    46
    Location:
    Melbourne Victoria
    Hi All,
    I'm trying to make a Calibration Page that times out after 30 seconds, this part is ok, i would like to add an onscreen count down time to this screen showing how long before the page closes and your returned to the Welcome Screen...See code below. It's mostly working except that the onscreen countdown just keeps overwriting the same place, and it goes to the Welcome screen after about 2 seconds.
    Any help is always appreciated.

    Code:
     If ShowingPage("Calibration Page") then Begin
     
     TextPos(335, 373);
     SetFontSize(20);
     
     DrawText('', 60 - TimerTime(3));
     Delay(1);
     If timertime(3) = 0 then;
    
    ShowPage("Welcome Screen")
    
     end
     

    Attached Files:

    Trevor, Mar 25, 2026
    #1
  2. Trevor

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,624
    Likes Received:
    204
    Location:
    Adelaide, Australia
    DrawText only writes the foreground. You need to erase the background first by drawing a filled rectangle.

    The semicolon is terminating the if statement. Remove it.
     
    Ashley, Mar 25, 2026
    #2
  3. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    550
    Likes Received:
    46
    Location:
    Melbourne Victoria
    Thanks Ash,
    I did look for the commend to erase the background but couldn't find anything to do it...

    Oops missed that,
    Will do that background square now...
     
    Trevor, Mar 25, 2026
    #3
  4. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    550
    Likes Received:
    46
    Location:
    Melbourne Victoria
    Yep, so far so good, thanks Ash.
     
    Trevor, Mar 25, 2026
    #4
  5. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    550
    Likes Received:
    46
    Location:
    Melbourne Victoria
    I know i'm missing something really stupid hear but when i run the code below all i get is a box saying 60 and it isn't changing...Any ideas will help...

    Code:
    If ShowingPage("Calibration Page") then
     Begin
     TimerSet(3,30);
     TextPos(335, 373);
     SetFontSize(20);
     DrawText('', 60 - TimerTime(3));
      Delay(1);
     SetBrushColor(clcyan);
     Rectangle(380, 370, 450, 400);
     If timertime(3) = 0 then
     ShowPage("Welcome Screen")
     end
     
    Last edited: Apr 7, 2026
    Trevor, Apr 7, 2026
    #5
  6. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    550
    Likes Received:
    46
    Location:
    Melbourne Victoria
    Found it,
    The line TimerSet(3,30)
    keeps resetting the value for the timer to 30.
    Took it out and all good now.
     
    Trevor, Apr 7, 2026
    #6
  7. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    550
    Likes Received:
    46
    Location:
    Melbourne Victoria
    OK,
    Next problem,
    It just keeps counting down even after passing 0, it then goes negative...
    What do i need to do to get it to change pages at or after 0.
    I did try If timertime(3) < 0 then
    And also If timertime(3) = "0:00:00" then
     
    Trevor, Apr 7, 2026
    #7
  8. Trevor

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,624
    Likes Received:
    204
    Location:
    Adelaide, Australia
    Timers count up not down. :)
     
    Ashley, Apr 7, 2026
    #8
  9. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    550
    Likes Received:
    46
    Location:
    Melbourne Victoria
    Yes but this line is out of the help on timer time, it does count down, looks like it does on the screen from 30 to 0 but then keeps going into negative. I set the time time to start at 30
    DrawText('', 60 - TimerTime(3));
     
    Trevor, Apr 7, 2026
    #9
  10. Trevor

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,624
    Likes Received:
    204
    Location:
    Adelaide, Australia
    But you are drawing 60 - TimerTime(3) so if the displayed time is going down the timer is going up. You need to stop at timer = 60

    Timers go up. If you set a start time it starts at that time and goes up. I've no idea why this is an option as it's basically useless. So yours starts at 30 so 60-30 = 30, then goes to 31 so 60-31=29 etc. When the timer goes past 60 you count goes -ve at you see.

    You may as well just start the counter at 0 then show 30-timer and stop at 30.
     
    Last edited: Apr 7, 2026
    Ashley, Apr 7, 2026
    #10
  11. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    550
    Likes Received:
    46
    Location:
    Melbourne Victoria
    I think I get it, I'll try on Thursday when I'm back at work. Thanks again. The help section is usually very good with these things.
     
    Trevor, Apr 7, 2026
    #11
  12. Trevor

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,624
    Likes Received:
    204
    Location:
    Adelaide, Australia
    The help is a bit misleading here. Because timers only count up, the only way to get a countdown timer is by subtracting its current value from a fixed value which is all the help is showing you.

    Another thing to think about is that you are writing the time value to the screen every scan (200mS) so you are repeating each value 5 times. This is wasting considerable resources. You should only be updating the screen every second when the timer ticks over.
     
    Ashley, Apr 7, 2026
    #12
  13. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    550
    Likes Received:
    46
    Location:
    Melbourne Victoria
    Thanks Ashley.
    Always helpful.
     
    Trevor, Apr 7, 2026
    #13
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.