ScriptTap
ModVariable

Command video guide

ModVariable

ModVariable calculates values for later commands: two-operand Basic math, a scalar Expression, or a formula across Array items. This Overview shows the choices without Test or Play. The three mode tabs provide working demonstrations.

Use In selects This Script Only or Script Thread. Match the context of inputs, declarations and consumers. Numeric Result Type selects Integer or Decimal; an already declared target must match. Basic combines L and R using addition, subtraction, multiplication or division and writes the named Variable. The destination is not automatically the left operand. Use Hex is Basic-only, hides numeric Result Type and changes literal operand interpretation; use compatible inputs and target. Turning it off preserves dormant operand text.

Expression uses one formula and a destination Variable. It supports numbers, earlier Integer/Decimal variables, whitespace, parentheses, +, -, *, / and unary signs, with a 256-character limit. Multiplication and division take priority unless parentheses change the grouping. It is not JavaScript or text manipulation.

Array requires an earlier declared Integer/Decimal target with matching Result Type and sufficient capacity. Target Start is the first output position; Count is the number of results. The A/B/C input rows map one to three declared numeric array ranges, each with its own Start. Formula aliases a, b, c refer to those rows, regardless of their actual family letters; i is the 1-based offset, not the absolute index.

Start/Count accept Integer literals or earlier Integer variables. Keep complete ranges inside declared capacities. Valid Count 0 writes nothing after setup validation. Unwritten slots within valid numeric input ranges contribute zero. Array validates and stages the whole batch before publishing, so rejected setup or any failed result writes no partial output and calculations read original inputs.

Integer rounds and clamps to the signed 32-bit range. Decimal retains up to 15 significant digits. Exact-zero division and nonfinite results leave the target unchanged and continue; inspect run warnings. True Mode changes clear outgoing mode-only fields. Review active fields before OK. This tour cancels its draft and does not run a script.

Overview

Step-by-step guide

  1. Step 01

    Mod Variable calculates values that later commands can use. It can combine two operands, evaluate a longer formula, or apply a calculation across array items. Use it for counters, measurements, coordinates, and other values that need to change during a script. This overview explains the options without playing a demonstration.

    ModVariable: Overview step 1: Mod Variable calculates values that later commands can use. It can combine two operands, evaluate a longer formula, or apply a calculation across array items. Use it for counters, measurements, coordinates, and other values that need to change during a script. This overview explains the options without playing a demonstration.
  2. Step 02

    Create a blank script for this option tour. The Basic, Expression, and Array tabs contain separate working examples, with the supporting commands needed to show each result.

    ModVariable: Overview step 2: Create a blank script for this option tour. The Basic, Expression, and Array tabs contain separate working examples, with the supporting commands needed to show each result.
  3. Step 03

    Name the new script, then open its editor. This tour will inspect one Mod Variable command and cancel its draft changes when finished.

    ModVariable: Overview step 3: Name the new script, then open its editor. This tour will inspect one Mod Variable command and cancel its draft changes when finished.
  4. Step 04

    Open Variables, find Mod Variable, and drag it into the script. Open the row you placed. The Mode menu offers Basic, Expression, and Array; choose the form that fits your calculation.

    ModVariable: Overview step 4: Open Variables, find Mod Variable, and drag it into the script. Open the row you placed. The Mode menu offers Basic, Expression, and Array; choose the form that fits your calculation.
  5. Step 05

    Use In selects the variable context. This Script Only uses local values. Script Thread shares values with related scripts in the same thread. Match the scope used by your inputs, declarations, and later commands. We will inspect this tour in local scope.

    ModVariable: Overview step 5: Use In selects the variable context. This Script Only uses local values. Script Thread shares values with related scripts in the same thread. Match the scope used by your inputs, declarations, and later commands. We will inspect this tour in local scope.
  6. Step 06

    For numeric calculations, Result Type selects Integer or Decimal. An already declared target must have the matching type. Choose Integer for rounded whole-number results, or Decimal when fractional results matter. This setting also applies to Expression and Array modes.

    ModVariable: Overview step 6: For numeric calculations, Result Type selects Integer or Decimal. An already declared target must have the matching type. Choose Integer for rounded whole-number results, or Decimal when fractional results matter. This setting also applies to Expression and Array modes.
  7. Step 07

    Basic combines the left operand, L, with the right operand, R. Operation offers addition, subtraction, multiplication, or division. The operands can be numbers or compatible earlier variables. Variable names the destination receiving the answer; it is not automatically the left operand.

    ModVariable: Overview step 7: Basic combines the left operand, L, with the right operand, R. Operation offers addition, subtraction, multiplication, or division. The operands can be numbers or compatible earlier variables. Variable names the destination receiving the answer; it is not automatically the left operand.
  8. Step 08

    Use Hex is a Basic-only option for hexadecimal operands. Notice that the numeric Result Type control is hidden while it is on. Use inputs and a target compatible with that mode. Turning the toggle off preserves its dormant operand text. We will return it to Off for the rest of this tour.

    ModVariable: Overview step 8: Use Hex is a Basic-only option for hexadecimal operands. Notice that the numeric Result Type control is hidden while it is on. Use inputs and a target compatible with that mode. Turning the toggle off preserves its dormant operand text. We will return it to Off for the rest of this tour.
  9. Step 09

    Expression replaces the two-operand form with one formula. Variable is still the destination. The formula can combine numbers and earlier Integer or Decimal variables. For example, parentheses can group an addition before multiplying its result. Use this mode when one Basic operation is not enough.

    ModVariable: Overview step 9: Expression replaces the two-operand form with one formula. Variable is still the destination. The formula can combine numbers and earlier Integer or Decimal variables. For example, parentheses can group an addition before multiplying its result. Use this mode when one Basic operation is not enough.
  10. Step 10

    Expressions support addition, subtraction, multiplication, division, parentheses, whitespace, and positive or negative signs. Multiplication and division take priority unless parentheses change the grouping. The expression limit is two hundred and fifty-six characters. This is a numeric formula, not a JavaScript program or a text transformation.

    ModVariable: Overview step 10: Expressions support addition, subtraction, multiplication, division, parentheses, whitespace, and positive or negative signs. Multiplication and division take priority unless parentheses change the grouping. The expression limit is two hundred and fifty-six characters. This is a numeric formula, not a JavaScript program or a text transformation.
  11. Step 11

    Array applies a formula to a range of items. Target is the declared Integer or Decimal destination array, and Start chooses its first output position. Count is the number of results, not the last index. Declare the destination earlier with Set Variable, using the matching type and enough capacity.

    ModVariable: Overview step 11: Array applies a formula to a range of items. Target is the declared Integer or Decimal destination array, and Start chooses its first output position. Count is the number of results, not the last index. Declare the destination earlier with Set Variable, using the matching type and enough capacity.
  12. Step 12

    The A, B, and C Array rows map up to three numeric input arrays, each with its own starting position. At least one input row is required. In the formula, lowercase a, b, and c mean the current values from those rows, regardless of their actual family letters. Lowercase i is the offset, starting at one, not the absolute array index.

    ModVariable: Overview step 12: The A, B, and C Array rows map up to three numeric input arrays, each with its own starting position. At least one input row is required. In the formula, lowercase a, b, and c mean the current values from those rows, regardless of their actual family letters. Lowercase i is the offset, starting at one, not the absolute array index.
  13. Step 13

    Target and input starts are one-based. Start and Count fields accept Integer literals or earlier Integer variables. Keep every complete range within its declared capacity. A valid Count of zero writes nothing; invalid setup is still rejected. Unwritten positions inside a valid numeric input range contribute zero, so initialize any values your calculation depends on.

    ModVariable: Overview step 13: Target and input starts are one-based. Start and Count fields accept Integer literals or earlier Integer variables. Keep every complete range within its declared capacity. A valid Count of zero writes nothing; invalid setup is still rejected. Unwritten positions inside a valid numeric input range contribute zero, so initialize any values your calculation depends on.
  14. Step 14

    Array validates the whole setup and stages every result before writing the destination. A bad range, incompatible input, division by zero, or another failed result prevents a partial update. This also lets a formula read its original input values before the staged output is published. Check run warnings if the expected change does not appear.

    ModVariable: Overview step 14: Array validates the whole setup and stages every result before writing the destination. A bad range, incompatible input, division by zero, or another failed result prevents a partial update. This also lets a formula read its original input values before the staged output is published. Check run warnings if the expected change does not appear.
  15. Step 15

    Integer results are rounded and limited to the signed thirty-two-bit range. Decimal results keep up to fifteen significant digits. Exact-zero division or a nonfinite answer leaves the target unchanged and allows the script to continue. Choose the result type and formula deliberately rather than relying on an invalid calculation.

    ModVariable: Overview step 15: Integer results are rounded and limited to the signed thirty-two-bit range. Decimal results keep up to fifteen significant digits. Exact-zero division or a nonfinite answer leaves the target unchanged and allows the script to continue. Choose the result type and formula deliberately rather than relying on an invalid calculation.
  16. Step 16

    Changing Mode clears fields belonging only to the outgoing mode. Review the active fields before using OK. This tour closes with the X without saving the draft or playing. Choose a mode tab for a complete example and a visible result.

    ModVariable: Overview step 16: Changing Mode clears fields belonging only to the outgoing mode. Review the active fields before using OK. This tour closes with the X without saving the draft or playing. Choose a mode tab for a complete example and a visible result.