Need some intel on a timing script that compares current time with an interval

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
diamondrail
Newbie
Posts: 18
Joined: Wed Jul 31, 2019 9:38 am

Need some intel on a timing script that compares current time with an interval

Post by diamondrail » Wed Jul 31, 2019 9:52 am

I am in the process of building one of my first scripts and need some advice on creating the code for the following (attached) algorithm.
Entered variables are:
Start time (based on current time zone)
End time (based on current time zone)
Wait time (in minutes)

What's the best and most efficient way to setup this script?
Also what's the best way to have an exit script? Hot keys?
Attachments
script.jpg
script.jpg (30.85 KiB) Viewed 207 times

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 504
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Need some intel on a timing script that compares current time with an interval

Post by Dorian (MJT support) » Wed Jul 31, 2019 2:03 pm

It seems to me this is something that can be achieved in the Scheduler, which may be preferable to having the script constantly running and waiting.

Below is a simple script which we can use to test. It just writes the time to a text file.

Code: Select all

//Get time and date
Year>TheYear
Month>TheMonth
Day>TheDay
Hour>TheHour
Min>TheMin
Sec>TheSec

//Variables
Let>TheVariable=%TheYear%-%TheMonth%-%TheDay%-%TheHour%-%TheMin%-%TheSec%

//Output
WriteLn>d:\mjt\files\txt\schedule.txt,,TheVariable
The attached image shows the scheduling options I used to start the script at 2pm and run every 5 minutes. I only want it to run at 2, 2.05, 2.10, and 2.15pm, and then reset until tomorrow. So in Advanced, I have set it to reset at 2.16pm.

The output in my text file looks like this :
2019-07-31-14-00-00
2019-07-31-14-05-00
2019-07-31-14-10-00
2019-07-31-14-15-00


However, if you want the script to do it and not the Scheduler, I think this should do what you want. You can change the times in the If> line to experiment.

Code: Select all

label>Start
hour>hh
min>mm

If>{(%hh%%mm%>=900) AND (%hh%%mm%<=2345)}
  MessageModal>"Action" script goes here
Else
  Wait>60
  goto>Start
endif

//Wait 45 minutes
wait>{(45*60)}
goto>Start
Attachments
schedule 01.png
schedule 01.png (133.36 KiB) Viewed 205 times
Always accepting custom script commissions. Message me or go here

Post Reply