Seeking help, I seem to be stuck with a seemingly silly question. I have 5 variables, and I need to reset A, B, and C among them. How should I go about it? My initial thought was to use a foreach loop, but it seems to handle all the variables. Can you advise me on what I should do?
A simple solution would be using a set variable to text action for each variable and placing %Delete%
for the value. No need for looping anything. Though if you’re set on a loop method, when I’m back at my computer tomorrow I can show you how that too.
Thank you for your reply. I would rather know how to loop. Because I want to achieve this function: set a group each time according to the needs, and then process the variables in the group.
I want to achieve this functionality: Each time, a new variable can be concatenated based on the variables within the group.
See my example macro below. You set each variable name and content in the text field in the For each
action, separated by a colon. You can change the delimiter if you’d like, but whatever you change it to, you have to update that in the RegEx in the Search
action directly below as well.
Let me know if you have any questions on it!
Download Macro(s): Set multiple variables by looping.kmmacros (6.3 KB)
Macro-Notes
- Macros are always disabled when imported into the Keyboard Maestro Editor.
- The user must ensure the macro is enabled.
- The user must also ensure the macro's parent macro-group is enabled.
System Information
- macOS 13.6.3
- Keyboard Maestro v11.0.2
Thank you for your response. Using line breaks to separate variables is a good idea, but for me, it's a bit challenging in practice: I have quite a few variables to organize, and their values can be lengthy, making it cumbersome to maintain them together.
Ah ok I see what you mean, thus wanting to be able to use the set variable action for each one since that gives you more text space to work with. I haven’t done it that way, but no doubt others have and will chime in soon.
Here is the approach I use to reset variables when I need to -- I undoubtedly came across this solution somewhere on this forum.
If you were creating your list of variables elsewhere in the macro, you can simply change the for each to Lines in variable instead.
Thank you for your reply, it has inspired me that I can seem to accomplish my purpose more easily!