Skip to content

XTML Expression System

Andreas Wagner edited this page Nov 16, 2025 · 1 revision

The XTML Expression System allows you to compute values dynamically within <xtml> blocks. It supports numeric, string, boolean, and array types, and provides operators for arithmetic, logical, comparison, and unary operations.


Data Types

  • Number: Represents numeric values (integers and decimals).
  • String: Represents text values.
  • Boolean: Represented as "1" (true) or "0" (false).
  • Array: A list of var elements.

Operators

Arithmetic

Operator Description Example
+ Addition or string concatenation 5 + 3 → 8
"Hello " + "World" → "Hello World"
- Subtraction 10 - 4 → 6
* Multiplication 2 * 3 → 6
/ Division 10 / 2 → 5
% Modulo 10 % 3 → 1

Comparison

Operator Description Example
== Equal to 5 == 5 → "1"
!= Not equal to 5 != 3 → "1"
< Less than 3 < 5 → "1"
<= Less than or equal 5 <= 5 → "1"
> Greater than 10 > 2 → "1"
>= Greater than or equal 2 >= 3 → "0"

Logical

Operator Description Example
&& Logical AND "1" && "0" → "0"
` `
! Logical NOT ! "0" → "1"

Unary Operators

Operator Description Example
++ Increment (prefix/postfix) ++i or i++
-- Decrement (prefix/postfix) --i or i--
- Unary minus -5 → -5
+ Unary plus +5 → 5

Expressions in XTML

Expressions are evaluated inside <xtml> blocks. You can store results in variables or return them from functions.

<xtml>
    var a = 5;
    var b = 10;
    var sum = a + b;
    var isEqual = (a + b) == 15;
</xtml>

Notes

  • Logical and comparison operations always return a var of type DT_BOOL ("true" for true, "false" for false).
  • Arithmetic on mixed types (e.g., string + number) will perform string concatenation if one operand is a string.
  • Unary operations (++, --) can be prefix or postfix and affect the variable directly if applied to a variable reference.

Clone this wiki locally