Set
Purpose: create or change a variable.

Fill in the variable name, the operator and the value, in that order. The Quick buttons fill in = 0, += 1 or -= 1. The variables known so far are listed below.
JSON
json
{ "set": { "var": "a", "value": 10 } }
{ "set": { "var": "a", "op": "+=", "value": 5 } }
{ "set": { "var": "f", "value": "${a} / 4.0" } }| Field | Required | Meaning |
|---|---|---|
var | Yes | Variable name |
value | Yes | Value or expression |
op | No | = (default), +=, -=, *=, /=, %= |
Number rules
- Integer with integer gives an integer, and division drops the fraction:
24 / 5 = 4. - If either side has a fraction (for example
4.0), so does the result:24 / 4.0 = 6.0. %,&,|,^,~,<<and>>only work on integers.
Result
Set is PASS, and the Actual column shows the value after setting. If the expression has an error (an undefined variable or a division by 0, for example), the round stops and is judged FAIL.
Example
| Steps | Result |
|---|---|
a = 10, += 5, -= 3, *= 2 | a = 24 |
b = a, /= 5 | b = 4 |
c = a, %= 7 | c = 3 |
f = a / 4.0 | f = 6.0 |
m = (a >> 1) & 0x0F | m = 12 |

Notes
- Variables carry across cases within a round and are cleared when each round starts; see Concepts › 6. Variables.
- Each round holds up to 256 numeric variables.
Download the sample script
Sample script
Before running it, start a Slave window on 127.0.0.1:502 and click Listen, then open the script with Open JSON in Script mode and click Run. See How to use the examples.
