Question Re Calculation Variable + Repeat Macro

I tried to create a repeat macro that can be applied across many macros. I didn't do a thorough search but I'm sure it's been done before. I'm hoping mine is streamlined - due to my applescript - but maybe not. I have 1 Q:

For the repeat macro to work, it has to switch to a 'helper_macro' ('execute helper_macro') but only on the last rep. (Like a lot of people), its been hard work, learning the language of variables. Instead of spending gads of hours trying to figure it out, I thought I would ask you guys. Hope you don't mind.

When my Count variable reaches the last repetition, is there a way to programmatically instruct the macro to execute a different (helper) macro. I'm hoping the Calculation variable can do tell the macro to execute a helper macro once, only on the last rep. Can it?

Below: 1, 'Export as a Trigger' (no repeat). 2, The repeat version of this same 'Export as Trigger' macro. and 3, The same repeat macro with the repeat part displayed.

If anyone wants to use the macro, I uploaded the Export_as_Trigger_Repeat macro below. To run it on your own computer, you would have to make one change to one action. I colorized that action (to green) and added a Comment.

Thank you in advance for any help with my Calculation question!

Export_as_Trigger_Repeat.kmmacros (10.3 KB)

1Export%20as%20Trigger

2Export-as-Trigger_Repeat

3Last%20part%20of%20repeat

— At the beginning of the macro, create a new variable called Repeat_Counter and set it to 0.

— At the end of each repeat, add a condition like:
If Repeat_Counter is Count, execute helper_macro

— After that condition, set Repeat_Counter to Repeat_Counter + 1

Basically, you're using Repeat_Counter to keep track of how many times you've done the repetition, and when that number gets to the final time around, it'll trigger helper_macro.

Thank you for your reply to my question. Any chance I can ask you can to give a simple test example? I'm not sure, what's the rationale for the final 'set repeat_counter to r_c + 1' ?

I tried your suggestion a bunch of times and couldn't get it to work. The first repeat counter is at the beginning but before the repeat loop?And your second and third statements are in a If, then, else statement? Or (?)

Post what you've tried and I'll take a look. The "set Repeat_Counter to Repeat_Counter + 1" step is to make the count go up each time.

Actually, here's a quick demo version.

Repeat Counter Demo.kmmacros (28.7 KB)

1 Like

This doesn't work. I imported it and it does nothing

Sometimes the simplest solution is best. We were both stuck on using an increment counter. The simpler way is to just place the alternate action after the repeat action in the KM sequence. Like this:

Executing A Different Action After Final Repeat.kmmacros (4.4 KB)

07%20PM