Logo

Operators

ZeroTrace supports dynamic operators (prefixed with _$) and variables.

Operator Syntax Rules

  1. Standalone or in variables: can be used directly or assigned to variables.
  2. Always starts with _$: identifies the token as an operator.
  3. Parentheses required: arguments must be inside (...) even for no-argument operators.
  4. Case-sensitive names: operator names must match exactly.

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 a normal 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()  # Random digit (0-9)

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

String Operations

_$uppercase(string)

Example: Input: _$uppercase('admin') Output: ADMIN

_$lowercase(string)

Example: Input: _$lowercase('Admin') Output: admin

_$reverse(string)

Example: Input: _$reverse('admin') Output: nimda

_$length(string)

Example: Input: _$length('admin') Output: 5

_$concat(str1, str2)

Example: Input: _$concat('user', '01') Output: user01

_$substring(str, start, len)

Example: Input: _$substring('password', 0, 4) Output: pass

_$replace(str, target, repl)

Example: Input: _$replace('admin123', '123', '456') Output: admin456

Random Character Generation

_$random_lowercase_letter(1)

Example: g

_$random_uppercase_letter(1)

Example: K

_$random_letter(1)

Example: R or h

_$random_special(1)

Example: ! or #

_$random_char(1)

Example: 4 or @ or q

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 generate dynamic values each run.

Important:

  1. Wrap operator expressions in quotes when assigning to variables.
  2. Reference variables with ${variable}$.
  3. Do not embed operators in normal string literals.
  4. Nested random operators are not supported. Example: _$random(1, _$random(2,5)) is invalid.

On this page