ScriptTap
IF

Command video guide

IF

IF decides whether a group of commands runs. When its rule passes, the script runs the commands inside the block, then continues after End IF. This introduction demonstrates OR: at least one condition must be true.

Create and name a separate script. Expand Variables and manually drag SetVariable into Live Script. Keep Single and Integer, name it i1, set its value to 3, and keep This Script Only. This supplies the value before IF reads it.

Expand Logic and manually drag IF after the assignment. The paired End IF is created automatically. Double-tap the IF frame. Mode selects OR (at least one), AND (every condition), XOR (exactly one, not odd parity), or RGB Confidence (Hex-color matching).

Set the first condition to i1 > 2. Add a second condition, i1 < 0. An IF supports up to five conditions; scroll the form as needed. The small red X at a row divider removes that condition.

Relationship offers =, <>, >, >=, <, <=, Between and Contains. Text equality and Contains ignore letter case. Number and Time comparisons use their values. Between includes both bounds; a time-only range can cross midnight. A comparison value can be a literal or a compatible variable written earlier.

Drag PromptMe from Advanced into the script, then move its frame between IF and End IF at the blue insertion line. Keep Standard, set Header to Matched, and add a Next button with Boolean output b1. Leave Use Toggles & Text off.

Manually drag another PromptMe after End IF, with Header Complete, a Done button and output b2. This outside confirmation runs whether the condition passes or fails. An optional ELSE can provide an alternative inside path.

Close the editor and use Play. With i1=3, the first condition is true and the second false, so OR displays Matched. Press Next to reach Complete, then Done to finish automatically. IF controls execution; it does not change the tested value.

Intro / OR

Step-by-step guide

  1. Step 01

    IF decides whether a group of commands runs. It checks conditions, runs the commands inside when its rule passes, then continues after End IF. We will use OR to check two numeric conditions and show which path ran.

    IF step 1: IF decides whether a group of commands runs. It checks conditions, runs the commands inside when its rule passes, then continues after End IF. We will use OR to check two numeric conditions and show which path ran.
  2. Step 02

    Open the main overlay menu, then choose Scripts.

    IF step 2: Open the main overlay menu, then choose Scripts.
  3. Step 03

    Tap New Script and choose Blank Script.

    IF step 3: Tap New Script and choose Blank Script.
  4. Step 04

    Scroll to the new row if needed. We will use a separate example and leave existing scripts unchanged.

    IF step 4: Scroll to the new row if needed. We will use a separate example and leave existing scripts unchanged.
  5. Step 05

    Open the new row's menu and choose Rename. Give the script a descriptive name, then tap OK.

    IF step 5: Open the new row's menu and choose Rename. Give the script a descriptive name, then tap OK.
  6. Step 06

    Select the new script, open the editor, and collapse the extra overlay controls.

    IF step 6: Select the new script, open the editor, and collapse the extra overlay controls.
  7. Step 07

    First we need a value to test. Expand Variables and drag Set Variable into the script. Double-tap its frame to configure it.

    IF step 7: First we need a value to test. Expand Variables and drag Set Variable into the script. Double-tap its frame to configure it.
  8. Step 08

    Keep Single mode and Integer. Name the variable i1. This supporting command defines the value before IF reads it.

    IF step 8: Keep Single mode and Integer. Name the variable i1. This supporting command defines the value before IF reads it.
  9. Step 09

    Set its value to three and keep This Script Only. Now tap OK.

    IF step 9: Set its value to three and keep This Script Only. Now tap OK.
  10. Step 10

    Collapse Variables and expand Logic. Drag IF after Set Variable. Its matching End IF is created with the block.

    IF step 10: Collapse Variables and expand Logic. Drag IF after Set Variable. Its matching End IF is created with the block.
  11. Step 11

    Double-tap the IF frame to open its conditions.

    IF step 11: Double-tap the IF frame to open its conditions.
  12. Step 12

    Mode changes the rule. AND requires every condition; XOR requires exactly one, not just an odd number; and RGB Confidence compares Hex colors. Keep OR here: at least one condition must be true.

    IF step 12: Mode changes the rule. AND requires every condition; XOR requires exactly one, not just an odd number; and RGB Confidence compares Hex colors. Keep OR here: at least one condition must be true.
  13. Step 13

    Enter i1 as Variable Name. Use a value declared earlier, and choose comparisons appropriate for its type.

    IF step 13: Enter i1 as Variable Name. Use a value declared earlier, and choose comparisons appropriate for its type.
  14. Step 14

    Relationship offers equal, not equal, greater or less, their inclusive versions, Between, and Contains. Text equality and Contains ignore letter case. Number and Time comparisons use their values.

    IF step 14: Relationship offers equal, not equal, greater or less, their inclusive versions, Between, and Contains. Text equality and Contains ignore letter case. Number and Time comparisons use their values.
  15. Step 15

    Between shows two bounds and includes both ends. A time-only range can cross midnight. Values can be literals or compatible earlier variables. For this example, switch back to greater than.

    IF step 15: Between shows two bounds and includes both ends. A time-only range can cross midnight. Values can be literals or compatible earlier variables. For this example, switch back to greater than.
  16. Step 16

    Enter two. The first condition is i1 greater than two. With our assigned value of three, this condition is true.

    IF step 16: Enter two. The first condition is i1 greater than two. With our assigned value of three, this condition is true.
  17. Step 17

    Tap Add Condition to add another row. One IF supports up to five conditions; scroll the form when necessary.

    IF step 17: Tap Add Condition to add another row. One IF supports up to five conditions; scroll the form when necessary.
  18. Step 18

    Use i1 again for the second condition.

    IF step 18: Use i1 again for the second condition.
  19. Step 19

    Choose less than for its relationship.

    IF step 19: Choose less than for its relationship.
  20. Step 20

    Enter zero. Three is not less than zero, so this condition is false. OR still passes because our first condition is true.

    IF step 20: Enter zero. Three is not less than zero, so this condition is false. OR still passes because our first condition is true.
  21. Step 21

    Use the small red X beside a row divider to remove a condition. Keep our two rows, then tap OK.

    IF step 21: Use the small red X beside a row divider to remove a condition. Keep our two rows, then tap OK.
  22. Step 22

    We need a visible result inside the block. Collapse Logic, expand Advanced, and scroll to PromptMe. Drag it into the script, then move its frame between IF and End IF. Release at the insertion line.

    IF step 22: We need a visible result inside the block. Collapse Logic, expand Advanced, and scroll to PromptMe. Drag it into the script, then move its frame between IF and End IF. Release at the insertion line.
  23. Step 23

    Open PromptMe, keep Standard mode, and set its header to Matched. This message will appear only when the IF rule passes.

    IF step 23: Open PromptMe, keep Standard mode, and set its header to Matched. This message will appear only when the IF rule passes.
  24. Step 24

    Add one button with caption Next and Boolean output b1, then tap OK. The button lets us continue after seeing the matched path.

    IF step 24: Add one button with caption Next and Boolean output b1, then tap OK. The button lets us continue after seeing the matched path.
  25. Step 25

    Drag another PromptMe after End IF. It must be outside the block, so it can confirm that execution continued whether the conditions passed or failed.

    IF step 25: Drag another PromptMe after End IF. It must be outside the block, so it can confirm that execution continued whether the conditions passed or failed.
  26. Step 26

    Open this prompt and set its header to Complete.

    IF step 26: Open this prompt and set its header to Complete.
  27. Step 27

    Add a button with caption Done. Enter b2 for its Boolean output, separate from the Next button. Keep text input off, then save with OK.

    IF step 27: Add a button with caption Done. Enter b2 for its Boolean output, separate from the Next button. Keep text input off, then save with OK.
  28. Step 28

    Set Variable assigns three. OR tests greater than two or less than zero. Matched is inside the IF block; Complete is after End IF. If OR were false, the script would skip the inside commands and continue outside. An optional ELSE can provide an alternative path.

    IF step 28: Set Variable assigns three. OR tests greater than two or less than zero. Matched is inside the IF block; Complete is after End IF. If OR were false, the script would skip the inside commands and continue outside. An optional ELSE can provide an alternative path.
  29. Step 29

    Close the editor to return to the home screen.

    IF step 29: Close the editor to return to the home screen.
  30. Step 30

    When the script is complete, simply use the Play button in the main overlay.

    IF step 30: When the script is complete, simply use the Play button in the main overlay.
  31. Step 31

    Matched appears because at least one condition is true. This is the command inside our IF block.

    IF step 31: Matched appears because at least one condition is true. This is the command inside our IF block.
  32. Step 32

    Press Next to continue past End IF.

    IF step 32: Press Next to continue past End IF.
  33. Step 33

    Complete is outside the block and confirms the script continued. IF changes which commands run; it does not change i1.

    IF step 33: Complete is outside the block and confirms the script continued. IF changes which commands run; it does not change i1.
  34. Step 34

    Press Done. The script finishes automatically. Use IF whenever later actions should depend on your script's values.

    IF step 34: Press Done. The script finishes automatically. Use IF whenever later actions should depend on your script's values.