Naar de inhoud

Operators

The 14 dynamic value generators — random data and string manipulation

2 min lezenDeze handleiding is alleen in het Engels beschikbaar.
Op deze pagina

Operators are _$-prefixed expressions that produce a value each time they run — random data, or a transform of another string. There are 14 of them.

Syntax rules

  1. Always starts with _$ — this marks the token as an operator.
  2. Parentheses are required — arguments go inside (...), even where a count defaults.
  3. Names are case-sensitive — _$random works, _$Random does not.
  4. Use directly as an argument, or assign to a variable.
# Direct usage
writeLn _$random(1,100)

# Assigned to a variable
_$VAR randomNum = "_$random(1,100)"
writeLn "${randomNum}$"

Available operators

_$random(from, to) — a random integer between from and to (inclusive). If to is below from the bounds are swapped automatically.

_$random(1, 10)     # e.g. 7

Nesting

Operators nest — arguments are evaluated recursively, innermost first.

_$random(1, _$random(2, 5))     # inner operator resolves before the outer one

Practical example

Generate a fresh random LED color each run:

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

or inline:

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

Index laden…

↑↓navigeren↵openenescsluiten