Variables
Declare, reference, and mutate values, and read live device states
Op deze pagina
Variables store and reuse values. A variable can hold a static value, an operator expression, or a device state.
Declaring and referencing
- Declare with
_$VAR. - Assign with
=, and the value must be quoted (double quotes). - Reference the value inside any argument with
${name}$.
# Static value
_$VAR isAdmin = "true"
writeLn "${isAdmin}$"
# Operator inside a variable
_$VAR delayTime = "_$random(500, 1500)"
delay "${delayTime}$"
# State inside a variable
_$VAR capsStatus = "_@capslockState"
writeLn "${capsStatus}$"Runtime assignment and math
_$VAR declares a variable when the line is read. To change a value while the script runs — for example to drive a repeat/while counter — use the commands below. They operate on the same global variables you reference with ${name}$.
| Command | Syntax | Effect |
|---|---|---|
set | set <var> <value> | Assign value to var |
add | add <var> <n> | var = var + n |
sub | sub <var> <n> | var = var - n |
mul | mul <var> <n> | var = var * n |
mod | mod <var> <n> | var = var % n (unchanged if n is 0) |
The math commands treat the variable as a signed integer in base 10; a non-numeric current value is read as 0.
set counter "0"
whileStart "${counter}$" < "3"
writeLn "Line ${counter}$"
add counter 1
whileEndHow a reference is resolved
When you use "${name}$", the interpreter looks up the global variable and then, if its stored value contains a marker:
- Evaluates operators if the value contains
_$. - Resolves a state if the value contains
_@— and lowercases the result.
Device states
State-backed values can be used standalone or embedded in text.
| State | Description | Raw output |
|---|---|---|
_@capslockState | CapsLock state | on / off |
_@numlockState | NumLock state | on / off |
_@scrolllockState | ScrollLock state | on / off |
_@usbState | USB connection state | on / off |
_@detectedOS | Detected operating system | Windows / Linux / macOS / iOS / Android / Unknown OS / OS Detection Disabled / Waiting... |
_$VAR usbStatus = "_@usbState"
writeLn "USB is: ${usbStatus}$"Practical examples
Dynamic delay
_$VAR delayTime = "_$random(500, 1500)"
delay "${delayTime}$"OS-aware branch
_$VAR os = "_@detectedOS"
IF "${os}$" is "windows"
terminal 'windows' powershell
IF_ENDCombining an operator and text
_$VAR username = "_$random(1, 100)"
writeLn "Generated user: ${username}$"