Operators
The 14 dynamic value generators — random data and string manipulation
Na tej stronie
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
- Always starts with
_$— this marks the token as an operator. - Parentheses are required — arguments go inside
(...), even where a count defaults. - Names are case-sensitive —
_$randomworks,_$Randomdoes not. - 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| Operator | Result | Example → output |
|---|---|---|
_$uppercase(s) | Uppercased copy | _$uppercase('admin') → ADMIN |
_$lowercase(s) | Lowercased copy | _$lowercase('Admin') → admin |
_$reverse(s) | Reversed string | _$reverse('admin') → nimda |
_$length(s) | Character count | _$length('admin') → 5 |
_$concat(a, b) | a joined to b | _$concat('user', '01') → user01 |
_$substring(s, start, len) | Slice from start, len chars | _$substring('password', 0, 4) → pass |
_$replace(s, target, repl) | Every target replaced by repl | _$replace('admin123', '123', '456') → admin456 |
Each takes a count of characters to generate.
| Operator | Character set | Example → output |
|---|---|---|
_$random_lowercase_letter(n) | a–z | _$random_lowercase_letter(1) → g |
_$random_uppercase_letter(n) | A–Z | _$random_uppercase_letter(1) → K |
_$random_letter(n) | a–z + A–Z | _$random_letter(1) → R |
_$random_number(n) | 0–9 | _$random_number(1) → 3 |
_$random_special(n) | !@#$%^&*() | _$random_special(1) → ! |
_$random_char(n) | letters + digits + specials | _$random_char(1) → @ |
Nesting
Operators nest — arguments are evaluated recursively, innermost first.
_$random(1, _$random(2, 5)) # inner operator resolves before the outer onePractical 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)