Create a text with variables and repeat it a n number of times

Hi everyone!
I thought I had the skills to do this type of macro, but I can't figure it out. I think it's pretty simple, and I hope I can explain it.
I need to create a "text by typing" (or pasting) in any text editor, Notepad for example, which has the following characteristics:
Given a sentence in a prompt you have to replace the colors and write the sentences in a text editor:
Example: "The colorPalette apple is on the table" will become
The red apple is on the table
The blue apple is on the table
The yellow apple is on the table
The green apple is on the table
etc.

In addition to this I need the final text to copy the lines, an n number of times which I initially define via a prompt.
Example: if I insert the number "3" into the initial prompt, the final text will be like this:
The red apple is on the table
The red apple is on the table
The red apple is on the table
The blue apple is on the table
The blue apple is on the table
The blue apple is on the table
The yellow apple is on the table
The yellow apple is on the table
The yellow apple is on the table
etc.

I created variables with all the colors I need that will be the same every time.

English is not my main language, I hope you can understand everything.

Thank you!

I think this should do what you want (if I have understood correctly). It prompts for you to type a sentence and set a number of repeats. It will replace "colorPalette" in the sentence you enter with the colors that are set in the Magenta Action, repeating each line the number that you set in the prompt.

You can alter the Magenta list Action to any number of colors (or any words).

EXAMPLE Replace Text and Repeat.kmmacros (5.7 KB)

Click to Show Image of Macro

1 Like

Dear Zabobon,
it's exactly what I was looking for! Thank you so much for your help :blush:
That's pretty much what I was doing too, but you did it in a much neater manner! Thanks also for teaching me a few things, which I finally figured out didn't go in my previous code.
Daniel

1 Like