Logo

Variables

Variables in ZeroTrace let you store and reuse values.

Variables can contain:

  • Static values (for example true, admin, 1234)
  • Operators (dynamic values, for example random numbers)
  • States (system values, for example CapsLock state)

Variable Syntax Rules

  1. Declaration starts with _$VAR.
  2. Assignment uses = and requires quotes around the value.
  3. Usage inside strings uses ${variable}$.
  4. Variables can hold operators (_$random()) or states (_@capslockState).

Valid Usage

# Static value
_$VAR isAdmin = "true"
writeLn "${isAdmin}$"

# Operator inside variable
_$VAR delayTime = "_$random(500, 1500)"
delay "${delayTime}$"

# State inside variable
_$VAR capsStatus = "_@capslockState"
writeLn "${capsStatus}$"

Invalid Usage

# Missing quotes around value
_$VAR username = admin

# Referencing without ${}$
writeLn "$isAdmin"

# Using variable without declaration
writeLn "${undefinedVar}$"

Accessing Variable Values

When you use "${variable}$", the interpreter:

  1. Looks up the global variable.
  2. Executes operators if the value contains _$.
  3. Resolves states if the value contains _@.

Supported States

State-backed variables can be used as standalone values or embedded in text.

StateDescriptionOutput
_@capslockStateCapsLock stateon / off
_@numlockStateNumLock stateon / off
_@scrolllockStateScrollLock stateon / off
_@usbStateUSB connection stateon / off
_@detectedOSDetected operating systemWindows / Linux / macOS / iOS / Android / Unknown OS / OS Detection Disabled / Waiting...

Valid Usage

_$VAR capsStatus = "_@capslockState"
writeLn "${capsStatus}$"

Also Valid Usage

_$VAR capsStatus = "_@capslockState"
writeLn "Capslock status is ${capsStatus}$"

Practical Examples

Dynamic Delay

_$VAR delayTime = "_$random(500, 1500)"
delay "${delayTime}$"

Device State Check

_$VAR usbStatus = "_@usbState"
writeLn "USB is: ${usbStatus}$"

Combining Operators and Text

_$VAR username = "_$random(1, 100)"
writeLn "Generated user: ${username}$"

Variables are the recommended way to combine operators and text output.

Important: variable values must be quoted, and references must use ${name}$.

On this page