If then else nested

Hello again, I am trying to make a rule with nested if statements. The goal is to make it possible to add 1, 2, or 3 medicines to a complete text. For example, if I add a medicine called Amoxicillin and press the OK button of Prompt User, it should paste the text with only that medicine. But if I press the Second Medicine button, it should open a new Prompt User to add the values of the second and so on for the third. I have two problems. The first is that after pressing the Second Medicine button, it immediately pastes the text. And the second is that the variable "Medication" seems not to change. It stays in the medicine that I put in the first Prompt User.


MEDICACION: Variables.kmmacros (5.0 KB)

My macro is 25MB then i can't upload but the link is: https://1drv.ms/u/s!AuC0881if1LwpG4pFRyHC1jNJrqC

THANK U FOR THE HELP.

I wonder whether you really need to nest your conditionals at all ?

Have you experimented with a series of checkboxes in the user prompt ?

( you could loop through a list of medication names with a For Each action, getting a dosage and appending a string only where the corresponding checkbox was ticked)


This kind of thing could be variously generalised for arbitrary lists, but if we start by stepping literally through a list and a matching hand-written prompt, then broadly this kind of thing:

Building dosages string for list of N medicines.kmmacros (12 KB)


Or even design the prompt to capture the dosages, if any, for each medication ?

See the various options at:

action:Prompt for User Input [Keyboard Maestro Wiki]

2 Likes