How to make it perform a set of actions if there are multiple lines in the text (after performing wrap text)?

I would a have text in my clipboard. I would be chopping the text down to multiple lines (if the text is long).
If there are more than 1 lines, I need to perform certain steps (steps a, b, c) for each line. Steps would be identical for each line.
Steps (a, b, c) would require the text (saved to the variable) of the specific line for which they are performing.
How to make it happen?

For example, let's assume the text would wrap after 20 characters.
Example 1: It's a small world. - 19 characters.
After text wrap it'd look like:
It's a small world.
I don't need to perform any actions.

Example 2: The beginnings of all things are small. - 39 characters.
After text wrap it'd look like:
The beginnings of
all things are small.
I need to perform actions (Steps a, b, c). In this case, steps would need text 'all things are small.' saved to a variable.

Example 3: One sunny morning, Lily was playing near a sparkling brook. - 59 characters.
After text wrap it'd look like:
One sunny morning,
Lily was playing
near a sparkling
brook.
I need to perform actions as following: Have text 'Lily was playing' saved to a variable. Perform steps a, b, c. Then have text 'near a sparkling' saved to a variable. And then again Steps a, b, c. Then have text 'brook.' saved to a variable. And then again Steps a, b, c. Total 3 times because there are additional 3 lines apart from the first line.

Right now I using the following macro to help me wrap the text automatically.

Wrap text at specified width.kmmacros (2.6 KB)

Assuming that you have wrapped the text, you can use the For Each action and the Lines In collection to iterate through the lines in the text.

You can have a variable track whether it is the first line or not and do nothing on the first line, something like:

  • Set variable First to 1
  • For Each Line
    • If variable First is not 1
      • do stuff
    • Set variable First to 0

You can process all but the first line that way.

1 Like