Pause and Resume a Macro?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
RNIB
Macro Veteran
Posts: 173
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Pause and Resume a Macro?

Post by RNIB » Thu Sep 05, 2024 3:15 pm

I have a drive with several thousand folders. The macro I've written opens the project files within each folder, makes various changes, saves the project to a new drive and then runs some checks on the new project files in other applications.

It does this by using a few different loops.

Loop A runs repeats the entire macro. It counts the number of folders on the drive and loops until A=count

Loops B & C run within Loop A and repeat other tasks, these loops count other things and continue until the loop = the respective counts.

The problem is that the amount of time it takes to run this macro on a drive due to the number of folders is quite considerable. I'd estimate 2-3 days. Therefore I'm wondering if there is a way to stop the macro and resume it where it left off at a different time?

I was thinking it could write to an .ini file /text file storing the loop number but I'm not entirely sure how that would work. I also need it to be able to complete its loop if it's stopped, rather than just stopping half way through a loop but I can't even begin to work out how to do that.

Is there a way of doing these things, or is there a better way of handling large tasks like this?

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Pause and Resume a Macro?

Post by JRL » Thu Sep 05, 2024 4:54 pm

I'd use an OnEvent>key_down that goes to a subroutine that sets a flag variable. When the script is at a point where it can stop, test for the value of the flag variable. If the flag variable is set to pause, go to a modal message that says close this message to continue. Also reset the flag variable.

Let>Flag=0

OnEvent sets flag to 1

If>Flag=1
Let>Flag=0
MDL>press ok to continue
Endif

RNIB
Macro Veteran
Posts: 173
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: Pause and Resume a Macro?

Post by RNIB » Fri Sep 06, 2024 7:53 am

Hmm, that's an interesting idea and certainly one that I think could be the answer to making sure it completes a loop before exiting.

The only thing is that the more I think about it, due to the size of the job I think it will be necessary to stop the macro and resume where it left off on a different day. In other words, the computer needs to be able to be used for other things and turned off rather than waiting for someone to click to continue.

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