Logo

🔢 Operators

ZeroTrace supports dynamic operators (prefixed with _$) and variables that can work together to create flexible, dynamic scripts.

📝 Operator Syntax Rules

  1. Standalone or in variables - Can be used directly or assigned to variables
  2. Always starts with _$ - Identifies it as an operator
  3. Parentheses enclose arguments - Required even for no-argument operators
  4. Case-sensitive names - Must match exactly as documented

Valid Usage:

# Direct usage
writeLn _$random(1,100)

# Variable assignment
_$VAR randomNum = "_$random(1,100)"
writeLn "${randomNum}$"

Invalid Usage:

writeLn "Value: _$random(1,100)"  # Embedded in string
writeLn _$Random(1,100)           # Incorrect case

🔢 Available Operators

Random Number Generation

_$random(from, to)  # Random integer between from and to

Example: Input: _&random(1, 10) Output: 7 (random number between 1 and 10)

_$random_number()  # Random digit (0-9)

Example: Input: _&random_number() Output: 3

🧩 Practical Examples

Dynamic Configuration

_$VAR ledR = "_$random(0,255)"
_$VAR ledG = "_$random(0,255)"
_$VAR ledB = "_$random(0,255)"
ledColor "${ledR}$" "${ledG}$" "${ledB}$"

or

ledColor _$random(0,255) _$random(0,255) _$random(0,255)

💡 Pro Tip: Combine variables and operators to create dynamic, adaptable scripts that change behavior each run!

Important: When using operators in variables:

  1. Wrap the operator in quotes for assignment
  2. Use ${variable}$ syntax when referencing
  3. Operators still can't be embedded in normal strings
  4. You cannot nest random operators inside each other. For example: _&random(1, _&random(2,5)) is invalid. Always use separate variables instead.

On this page