ScriptTap
ModVariable

Command video guide

ModVariable

ModVariable calculates a value that later script commands can use. Basic combines two operands with addition, subtraction, multiplication or division. It does not tap, type into another app, or display a result by itself.

Create and name a separate script. Manually drag SetVariable from Variables, keep Single/Integer, and assign i1=5 with This Script Only. This supplies the value before the calculation.

Manually drag ModVariable after the assignment. Open its frame and keep Basic. Expression supports a longer arithmetic expression; Array transforms declared numeric ranges in a batch.

Use In: This Script Only keeps the result local; Script Thread shares it within the parent script thread. Keep local scope for this example. Result Type: Integer rounds to whole numbers with signed 32-bit limiting; Decimal keeps fractional results using up to 15 significant digits. An existing destination must match the selected numeric result type.

Set destination i1, Operation L+R, left operand i1 and right operand 2. Operands may be numeric literals or compatible variables written earlier. This reads the old value and writes the calculated answer back to the same destination.

Use Hex: Basic-only hexadecimal interpretation. Literal operands use six Hex digits (optional # or 0x prefix); Decimal variable operands are rounded and limited before the Hex operation. Use a Hex destination such as h1 for a Hex result. Result Type is hidden while Hex is on. This ordinary toggle preserves dormant operands. Keep it off here. Division by exact zero, invalid/nonfinite numeric input or a nonfinite result writes no answer, logs a warning and continues.

To make the calculation visible, manually drag Display after it. Keep Once, choose Variable source i1, select a clear screen area, and set lifespan to 10000 ms. Display supports numeric variables directly; PromptMe's header-variable resolution is String-only.

Manually drag a supporting PromptMe after Display. Keep Standard, use Header Complete, and add a Done button with Boolean output b1. Leave Use Toggles & Text off. This is a final confirmation, not the numeric-output mechanism.

Close the editor and use Play. Display shows the actual calculated 7 for its configured ten-second lifespan. Complete then appears; press Done to finish automatically. The stored answer is available to later commands.

Basic

Step-by-step guide

  1. Step 01

    Mod Variable calculates new values for later script commands. Basic combines two numbers using addition, subtraction, multiplication, or division. We will add two to a stored value, then display the result on screen.

    ModVariable step 1: Mod Variable calculates new values for later script commands. Basic combines two numbers using addition, subtraction, multiplication, or division. We will add two to a stored value, then display the result on screen.
  2. Step 02

    Open the main menu, then Scripts.

    ModVariable step 2: Open the main menu, then Scripts.
  3. Step 03

    Create a new blank script.

    ModVariable step 3: Create a new blank script.
  4. Step 04

    Find the new script at the bottom of the library.

    ModVariable step 4: Find the new script at the bottom of the library.
  5. Step 05

    Open its options, choose Rename, and pick a descriptive name.

    ModVariable step 5: Open its options, choose Rename, and pick a descriptive name.
  6. Step 06

    Select the new script and open the editor. Collapse the extra overlay controls if needed. If Android asks, allow screen capture.

    ModVariable step 6: Select the new script and open the editor. Collapse the extra overlay controls if needed. If Android asks, allow screen capture.
  7. Step 07

    Start with a value for the calculation. Expand Variables and drag Set Variable into the script.

    ModVariable step 7: Start with a value for the calculation. Expand Variables and drag Set Variable into the script.
  8. Step 08

    Open the frame. Keep Single mode, and choose Integer as the variable type.

    ModVariable step 8: Open the frame. Keep Single mode, and choose Integer as the variable type.
  9. Step 09

    Use i1 as the variable name, with a starting value of five. Keep This Script Only and tap OK. This command provides the value before the calculation runs.

    ModVariable step 9: Use i1 as the variable name, with a starting value of five. Keep This Script Only and tap OK. This command provides the value before the calculation runs.
  10. Step 10

    Now drag Mod Variable below the assignment. Its position matters: the starting value must exist before we use it.

    ModVariable step 10: Now drag Mod Variable below the assignment. Its position matters: the starting value must exist before we use it.
  11. Step 11

    Open Mod Variable and its Mode menu. Basic uses two operands. Expression and Array handle more complex calculations. Keep Basic for this example.

    ModVariable step 11: Open Mod Variable and its Mode menu. Basic uses two operands. Expression and Array handle more complex calculations. Keep Basic for this example.
  12. Step 12

    Use In controls the result's scope. This Script Only keeps it local. Script Thread shares it across the parent script's call tree. Keep the same local scope as our starting value.

    ModVariable step 12: Use In controls the result's scope. This Script Only keeps it local. Script Thread shares it across the parent script's call tree. Keep the same local scope as our starting value.
  13. Step 13

    Result Type can be Integer or Decimal. Integer rounds to a whole number within its supported range. For fractional answers, choose Decimal and a Decimal destination, such as d1. We will keep Integer.

    ModVariable step 13: Result Type can be Integer or Decimal. Integer rounds to a whole number within its supported range. For fractional answers, choose Decimal and a Decimal destination, such as d1. We will keep Integer.
  14. Step 14

    Enter i1 as the destination. This replaces the stored value with the calculation's result. You can also write to another variable of the matching type.

    ModVariable step 14: Enter i1 as the destination. This replaces the stored value with the calculation's result. You can also write to another variable of the matching type.
  15. Step 15

    The Operation menu offers plus, minus, multiply, and divide. L and R mean left and right operands. Choose plus.

    ModVariable step 15: The Operation menu offers plus, minus, multiply, and divide. L and R mean left and right operands. Choose plus.
  16. Step 16

    Operands can be numbers or earlier numeric variables. Enter i1 on the left and two on the right. The command will read the current value, add two, and store the answer back in i1.

    ModVariable step 16: Operands can be numbers or earlier numeric variables. Enter i1 on the left and two on the right. The command will read the current value, add two, and store the answer back in i1.
  17. Step 17

    Use Hex interprets literal operands as six-digit hexadecimal values. Use a Hex destination, such as h1, for a Hex result. The Result Type menu is hidden in this mode. Keep Hex off for our numeric example. This toggle preserves the retained operands.

    ModVariable step 17: Use Hex interprets literal operands as six-digit hexadecimal values. Use a Hex destination, such as h1, for a Hex result. The Result Type menu is hidden in this mode. Keep Hex off for our numeric example. This toggle preserves the retained operands.
  18. Step 18

    Use a nonzero divisor. Division by zero or a nonfinite result leaves the destination unchanged, logs a warning, and continues the script. Tap OK to save our valid calculation.

    ModVariable step 18: Use a nonzero divisor. Division by zero or a nonfinite result leaves the destination unchanged, logs a warning, and continues the script. Tap OK to save our valid calculation.
  19. Step 19

    To see the numeric answer, expand Device and drag Display after Mod Variable. Display can show a variable's actual value.

    ModVariable step 19: To see the numeric answer, expand Device and drag Display after Mod Variable. Display can show a variable's actual value.
  20. Step 20

    Open Display. Keep Once mode, switch its source to Variable, and enter i1. This supporting command reads the result after the calculation.

    ModVariable step 20: Open Display. Keep Once mode, switch its source to Variable, and enter i1. This supporting command reads the result after the calculation.
  21. Step 21

    Choose a clear area for the answer. Open the area selector, resize the box, and use the check mark to return.

    ModVariable step 21: Choose a clear area for the answer. Open the area selector, resize the box, and use the check mark to return.
  22. Step 22

    Set its lifespan to ten thousand milliseconds, giving us ten seconds to see the answer. Keep the other display settings at their defaults and tap OK.

    ModVariable step 22: Set its lifespan to ten thousand milliseconds, giving us ten seconds to see the answer. Keep the other display settings at their defaults and tap OK.
  23. Step 23

    Add Prompt Me after Display as a final confirmation. The numeric answer comes from Display; this prompt simply shows that execution reached the next command.

    ModVariable step 23: Add Prompt Me after Display as a final confirmation. The numeric answer comes from Display; this prompt simply shows that execution reached the next command.
  24. Step 24

    Keep the regular Standard prompt, and give it the header Complete.

    ModVariable step 24: Keep the regular Standard prompt, and give it the header Complete.
  25. Step 25

    Add one button named Done, using b1 for its Boolean output. This gives us a clear way to finish the confirmation. Tap OK.

    ModVariable step 25: Add one button named Done, using b1 for its Boolean output. This gives us a clear way to finish the confirmation. Tap OK.
  26. Step 26

    The script now assigns five, adds two, displays the answer, and shows the confirmation. Close the editor to test it.

    ModVariable step 26: The script now assigns five, adds two, displays the answer, and shows the confirmation. Close the editor to test it.
  27. Step 27

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

    ModVariable step 27: When the script is complete, simply use the Play button in the main overlay.
  28. Step 28

    Display shows seven. Set Variable supplied five, and Mod Variable added two before the next command used the result.

    ModVariable step 28: Display shows seven. Set Variable supplied five, and Mod Variable added two before the next command used the result.
  29. Step 29

    After ten seconds, Display closes and Complete appears. The script has reached its final confirmation.

    ModVariable step 29: After ten seconds, Display closes and Complete appears. The script has reached its final confirmation.
  30. Step 30

    Press Done. The script finishes automatically. Use Basic when later actions need a value calculated from two numbers or numeric variables.

    ModVariable step 30: Press Done. The script finishes automatically. Use Basic when later actions need a value calculated from two numbers or numeric variables.