Jump to content
Macro Express Forums

Automatically Resume/Reschedule Macros?


topher

Recommended Posts

I have Macro Express installed on a PC we keep in our server room. This PC is logged in to my company's network all the time. I have created several scheduled ME macros to open MS Access and run Access macros. We're in an old building that occassionally has power failures. We've recently set this PC up so that it will automatically power on and log in to the network when recovering from a power outage.

 

My question is, if a power outage occurs at 4am and everything is restored at 5am, but I have an ME macro scheduled at 4:30am, can ME look to see that the macro did not run when scheduled and run it accodingly?

Link to comment
Share on other sites

if a power outage occurs at 4am and everything is restored at 5am, but I have an ME macro scheduled at 4:30am, can ME look to see that the macro did not run when scheduled and run it accodingly?
No, sorry. But this is something we're working on.
Link to comment
Share on other sites

But you can add a macro to do this. Simply log all the runs in your normal macro and then have a macro that runs at startup. I would start it with an option for a human to cancel and have a timed default so that if a human doesn't say "No" in 60 seconds it will execute. In there it can check your logs and see if a job had been performed in the last 60 minutes, or whatever logic you have, and if not launch the missed macro. And of course there are many ways to log and make these decisions of course, this is just a general suggestion.

Link to comment
Share on other sites

  • 2 weeks later...

This topic has come up for me recently too.... I have a Macro that runs for 6+ hours every day. It begins at a specified time, then it repeats itself every 25 Hours. The problem I run into is that if the PC is rebooted, then the 25 hour clock is reset to 0 and it won't run until the 25 hours are expired again.

 

I have been toying with an idea to have the start time logged to an INI File and change my macro to instead check this time slot every hour and when it is greater then 25 hours since the last run, it runs again. But I've been having trouble putting this together logically. It sounds good, but I'm just not exactly sure of the logic to put it all together.

 

Any Ideas to get me started???

 

Thanks!

Link to comment
Share on other sites

<br />This topic has come up for me recently too.... I have a Macro that runs for 6+ hours every day. It begins at a specified time, then it repeats itself every 25 Hours. The problem I run into is that if the PC is rebooted, then the 25 hour clock is reset to 0 and it won't run until the 25 hours are expired again.<br /><br />I have been toying with an idea to have the start time logged to an INI File and change my macro to instead check this time slot every hour and when it is greater then 25 hours since the last run, it runs again. But I've been having trouble putting this together logically. It sounds good, but I'm just not exactly sure of the logic to put it all together.<br /><br />Any Ideas to get me started???<br /><br />Thanks!<br />
<br /><br /><br />

You're going to need 2 macros, M1 and M2.

 

M1 is the macro you've described above, scheduled to run hourly starting at hh:mm nn minutes after the start of every 25 hours.

The first thing macro M1 will do is to load variables N1 thru N5 with, respectively, the current year, month, day, hour and minute, then write these variables either to a specific key reserved for your use in the registry, or to an .ini file if you prefer.

 

M2 is a macro scheduled to run only at startup, whose purpose is to run M1 once if needed, then modify M1's starting time (code to do this is below).

M2 contains this logic.

- load variables N1-N5 with, respectively, the current year, month, day, hour and minute

- load variables N6-N10 with the values last stored in the registry or .ini file

- compare n1-n5 with n6-n10 and decide when M1 must next be run

* convert n1-n3 to Julian, multiply by 1440 to convert to minutes, add n4*60 plus n5 to get the time in minutes that M1 was last run

* convert n6-n8 to Julian, multiply by 1440 to convert to minutes, add n9*60 plus n10 to get the current date and time in minutes

* if M1 should already have run one or more times, run M1 now (or use a different rule to suit your needs)

* determine hours and minutes of when M1 should next run into N11-N12

* determine the difference between N11-N12 and N4-N5 into N13-N14

* add N13-N14 to N4-N5 into N15-N16

* if N15-N16 are now, then run M1 and delay 1 minute

* schedule M1 to run every 25 hours starting at N15-N16 (code to do this is below)

 

The conversion to Julian is something you need to work out, or you can purchase a copy of PGM Library, which contains this functionality (NOTE: this is sound advice, but you should be aware that I am one of the developers of this product!).

 

<SPKEY:0030><MOVETOTRAY:Macro ExpressF:F:0:0><LCLK><WAITWIN2:000000:000010:Macro Express - Macro Explorer><TEXTTYPE:<ALT><ALT>mhM1<ALT>f<ESC>><DELAY:1><TEXTTYPE:<ALT><ALT>mp><DELAY:1><TEXTTYPE:<ALT>v><DELAY:1><TEXTTYPE:<ALT>s<ALT>s<TAB><ENTER>><DELAY:1><TEXTTYPE:<TAB><TAB><TAB><TAB>>

This locates the cursor on the hours part of the start time. I'll leave the rest of this for you to work out (i.e. changing minute, then saving the new start time).

Link to comment
Share on other sites

Maybe I'm missing something...

 

Can't the scheduled macro just save a date-coded notation to file on the hard drive stating whether it has run already that day and then a startup macro (which would be run if the machine was shut down due to a power outage) check the notation, compare the date code in aforementioned file to see if the scheduled macro has run, and if not, run it?

 

It seems elementary to me, but then, I'm an arrogant amateur! ;-)

Link to comment
Share on other sites

The problem arises when dealing with the next scheduled starting time of your macro.

 

Suppose the macro runs at 3pm on Monday, 4pm on Tuesday, then the machine crashes. The "run macro every 25 hours" bit is fine, but the new starting time is going to be related to when the machine was restarted, not to when the macro was last run.

Link to comment
Share on other sites

The problem arises when dealing with the next scheduled starting time of your macro.

 

Suppose the macro runs at 3pm on Monday, 4pm on Tuesday, then the machine crashes. The "run macro every 25 hours" bit is fine, but the new starting time is going to be related to when the machine was restarted, not to when the macro was last run.

 

 

D'oh... I was missed Cory's answer which was essentially the same as mine and didn't realize the topic had changed to a 25 hour clock... :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...