Logo

๐Ÿงฉ Variables

Variables in ZeroTrace allow you to store and reuse values, making your scripts more dynamic and organized.

Variables can contain:

  • Static values (like true, admin, 1234)
  • Operators (dynamic data, e.g., random numbers)
  • States (system states, e.g., CapsLock on/off)

๐Ÿ“ Variable Syntax Rules

  1. Declaration always starts with _$VAR
  2. Assignment uses = and requires quotes around the value
  3. Usage inside strings requires the syntax: ${variable}$
  4. Dynamic Content: 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 a variable inside a string ("${variable}$"), it will:

  1. Check global variables for a match.
  2. If the value contains an operator (_$), it will execute it dynamically.
  3. If the value contains a state (_@), it will check the actual device/system state.

๐Ÿ”„ Supported States

Usage inside/between strings are not supported.

StateDescriptionOutput
_@capslockStateCapsLock stateON / OFF
_@numlockStateNumLock stateON / OFF
_@scrolllockStateScrollLock stateON / OFF
_@usbStateUSB connection stateON / OFF

Valid Usage:

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

Unsupported 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}$"

You can nest operators and states inside variables to create powerful dynamic scripts!

Important: Variables must have their values wrapped in quotes, and referenced with the correct syntax.

On this page