WaitUntil


CamEra

Recommended Posts

Hi,

I am trying to use a StartUp sequence where I want to start another sequence on the quarter hour. To test it out I used the code below just to set it to a set minute a few minutes later than my present time. I started the application at 45 minutes but it did not wait until 9:58 before it produced the output line, it happened immediately

private string New

private Hour

private Minute

Hour=Floor(SysTime()%86400/3600)

Minute=Floor(Systime()%3600/60)

Minute=58

New=(DoubleToStr(hour) +"h"+DoubleToStr(Minute)+"m")

WaitUntil(New)

?New

George

Link to comment
Share on other sites

Well, I'd actually do it more directly:

new = floor((systime() + 2*60) / 3600) * 3600 + 58*60

waituntil(new)

I left the simple math in there for clarity. Floor(x/y)*y basically rounds x down to the nearest y multiple. I'm rounding down to the hour point. I added 2*60 or 2 minutes so that if the time is > 58 minutes of the hour is will actually round up to the next hour. Then I add 58 minutes to the hour to get the right time.

Its usually better to just do math on the time itself since its in seconds.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.