PRO
dbeard
USA
Asked
— Edited
Resolved by JustinRatliff!
Depending on the time of the day, I want my robot to do one thing or a different thing. I cant figure the logic out to make something like below to happen.
I am hoping someone can give me some hints.
Here is my script
If ($time > "9:30:00" and $time "16:00"00" and $time < "09:30:00") print("to the other thing") endif
Thanks in advance.
Hi I think you can use this function:
WaitUntilTime( hour, minute ) Waits until the specified time. The script will stop at this command and not continue until the specified time. The time is declared in 24 hour format. Example: WaitUntilTime(17, 30)
Or you can try your way first by assigning the $time to another variable and comparing it using the 24 hour format as above
Hope this helps
regards
Try this:
There are a few things syntax-wise wrong:
I don't think you can compare the times like that either. I'll look into it though.
This is a bit complex but it will do what you want using the method you showed. What it does is convert the time strings to numbers by simply removing the colons. Then the comparison compares those numbers to the current time (also converted to a number). Be sure to always put in all 3 numbers. Each can be one or 2 digits as needed.
If you wanted to dispense with the ConvertTimesToNumbers Goto routine, you could put the times in as numbers by leaving out the colons yourself. For example: "9:30:00" would be "93000"
The only thing that would still need converting would be the current time. If you did it that way the code could be:
My 2 cents here, I like PTP's code example. Similarly, here is how I kick off or don't kick off an exercise reminder from my int script. It only kicks off between 8am and 9pm.
Thanks to everyone. Sometimes I just over think things.