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
- Declaration starts with
_$VAR. - Assignment uses
=and requires quotes around the value. - Usage inside strings uses
${variable}$. - 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:
- Looks up the global variable.
- Executes operators if the value contains
_$. - Resolves states if the value contains
_@.
Supported States
State-backed variables can be used as standalone values or embedded in text.
| State | Description | 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... |
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}$.