Time

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
Ross Lainchbury
Newbie
Posts: 5
Joined: Sat Dec 27, 2003 3:45 am

Time

Post by Ross Lainchbury » Wed Jan 28, 2004 4:50 am

How can I add Time ie Now + 30 mins
Have searched forums but cannot find any ans
probaly me but any help would be appreciated.
Ross of Christchurch New Zealand

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Jan 28, 2004 6:49 am

Hi Ross.....

:idea: Here is one way that passed simple testing. This will work using Macro Scheduler commands:
//Assumes AM/PM measures. Need to modify for 24 hour measures.

Let>Advance=30
GetTime>Now
Hour>Hours
If>%Hours%Hours=%Hours%-12

Label>NextTime
Min>Minutes
Sec>Seconds
Position> ,%Now%,1,Space
MidStr>%Now%,%Space%,3,AMPM
Let>Now=%Hours%:%Minutes%:%Seconds%%AMPM%

Label>AdvanceTime
//Need to modify this area if Advance>60
Let>Minutes=%Minutes%+%Advance%
If>%Minutes%Minutes=%Minutes%-60
Len>%Minutes%,LM
If>%LM%=2,AddHour
//Comment out the next line to stop leading "0" on the minutes.
Let>Minutes=0%Minutes%

Label>AddHour
Let>Hours=%Hours%+1
If>%Hours%ChangeAMPM
Let>Hours=%Hours%-12
If>%AMPM%=AM,MakePM

Label>MakeAM
Let>AMPM=AM
Goto>End

Label>MakePM
Let>AMPM=PM

Label>End
Len>%Hours%,LH
If>%LH%=2,Finish
//Comment out the next line to stop leading "0" on the hours.
Let>Hours=0%Hours%

Label>Finish
Let>Later=%Hours%:%Minutes%:%Seconds%%AMPM%
MessageModal>Time now is %Now%%CRLF%Time later is %Later%
The amount of time to look ahead is in the variable %Advance%. I made it a variable to make it easier to adjust the routine for different time advances. Should check this script out using times after 30 minutes in the hour, and hours equal 11. Looks good, but I have not bothered to change system times to do extensive testing. Just wanted to get you on the way....

:idea: Could also do something using VBScript
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts