DocsVariablesCalculate

Calculate a math expression into a variable in RunMacro

RunMacro RunnerRunMacro 3.5+

The Calculate command evaluates a math expression (add, subtract, multiply, divide, floor-divide, modulo, exponent) and stores the result in a variable.

Dialog & quick setup

RunMacro Calculate command configuration dialog showing parameter fields
Configuration dialog and parameter fields for the Calculate command in RunMacro.
  1. Add a Variables › Calculate command.
  2. Set the result variable.
  3. Enter the expression, using [var_name] for numeric variables (e.g. [count] + 1).
  4. Save.

Options reference

Result variable

The variable that stores the computed result.

Expression

The arithmetic expression. Reference numeric variables via [var_name]; supports + - * /, floor-division //, modulo %, exponent **, and parentheses ( ).

Modes & when to use

RunMacro Runner

Best for

  • Increment/decrement a counter in a loop.
  • Compute a sum, difference, or derived value.
  • Process numbers before filling a form.

Use an alternative when

  • Do not use it for string concatenation or arbitrary Python; use it for supported numeric expressions.
Before you run
  • Add Calculate to the macro.
  • Prepare the data or target that Calculate will use.

Example workflow

Example: increment a counter each loop

  1. Declare Variable count = 0.
  2. In the loop: Calculate count = [count] + 1.
  3. Use {count} to show the run count.
Expected result: After execution, Calculate completes the described action and makes its result available to the next step.

Tips & limitations

In expressions, reference variables with [name] (square brackets), unlike {name} used in text fields.
  • Variable syntax uses [name]; malformed expressions, missing variables, or division by zero fail.

Applies to RunMacro 3.5+ · RunMacro Runner · Windows 10/11

RunMacro robot

Robots do the work. Your time is yours.

Create a robot in minutes, no coding needed. Reliable execution, remote management, transparent costs — and you always stay in control.