I am smart enough to know that the attached macro is inefficient/cave-person, but I'm not smart enough to know how to make it better.
I want to prompt for a list of names, and output a line that says for each name (and for bonus points, chopping off blank lines):
- Waiting for NAME (since May 8, 2024) #WF
I looked at For Each...but couldn't figure it out. Help me learn?
I also tried to just ask for one variable and parse comma separated values (but then ran into regex):
Input: scott, phil, jim, janet
output:
- Waiting for scott (since May 8, 2024) #WF
- Waiting for phil (since May 8, 2024) #WF
- Waiting for jim (since May 8, 2024) #WF
- Waiting for Janet (since May 8, 2024) #WF
There are probably about 129 different ways to do this :), here's one:
Download Macro(s): waiting for….kmmacros (3.3 KB)
Macro screenshot
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 14.4.1
- Keyboard Maestro v11.0.2
I used the Prompt for Snippet action to gather four names, and then a regular expression replaces each name with the name surrounded by your desired text. I think the output is what you were trying to get?
-rob.
3 Likes
While @griffman has shown you the regex method, here's the "For Each..." way in case it's useful in future projects. It's especially nice because it has a preset for "lines in a collection" and can automagically ignore blank lines.
Waiting for....kmmacros (3.6 KB)
Image
1 Like
Thanks SO MUCH @Nige_S and @griffman ! I have two functional macros AND I learned something from both cases.
I owe you both a beer.