Shop OBEX P1 Docs P2 Docs Learn Events
Timer_plus_countdown check for timeout — Parallax Forums

Timer_plus_countdown check for timeout

I have spin code
If timer.showTimer > string("00:00:00.00 ")
that uses theTimer_plus_countdown to count down then check for time out so it can bail out of a methoud.
The comparison will not work and im baffled why.

Comments

  • tomcrawfordtomcrawford Posts: 1,126
    edited 2017-01-26 16:58
    'cause spin doesn't directly support string data type.

    Edit: I should have suggesting looking in OBEX using search key "string". EndEdit
  • From the snippet you've posted, I'd guess that the timer.showTimer method is displaying the timer to the debug terminal. That's not the same thing as returning a value to the code. In addition, the internal representation of the timer will not be a sequence of printable characters, but a number. If you have access to that number, you can just compare to it directly, kind of like this:
      if timer.internalTime > 0
        'do something here
    
  • Ok it seems that showTimer cannot be used that way. To test the time you must use the registers.....
    rdReg(reg) as in If (rdReg(1) > n) AND (rdReg(2) > n) AND (rdReg(3) > n)
    rdReg(4) for Days
    rdReg(3) for Hrs
    rdReg(2) for Min
    rdReg(1) for Sec
    rdReg(0) for ms
Sign In or Register to comment.