Skip to content

Expression reference

The language of {{ }} in a document and of the binding attributes that take an expression: :if, :visible, class:*, style:*, attr:*, attrif:*, pulse:*, :rml, :value, :checked, :world and :focus-request. A on:* holds statements made of the same expressions. :for and alias:* take a path, not an expression.

Literals

Literal Form
Number Digits with at most one . and an optional leading -: 3, 0.25, 5., -.5, -2; a number cannot start with . and has no exponent. Every number is a double.
Text Single quotes: 'Red'. \' is a quote and \\ a backslash; any other backslash stays as it is.
Boolean true, false.

Names and paths

A name starts with a letter and goes on with letters, digits, _ and .. Player.Name reads a member, Items[0] or Items[i + 1] an element (the index is cut to a whole number), Items.size the length of an array. ev.<name> reads a parameter of the event in a on:* (event reference); a parameter the event does not carry is empty.

The first name of a path is looked up as a field of the view model, then as a alias:* or :for name of the element or an ancestor, then as a field whose name differs only in case. When two fields match that way, a warning names both and the one used. A path of two or more names that matches none of these reads <Field> of the view model named by its first name (Other models): ui.Theme reads Theme of the model ui. The element's own model is read with or without its own name in front of a field.

state.<name> inside a component reads the value declared by its <state>; the name state is reserved, and a write to it never reaches the game (Local state).

Operators

From the strongest binding to the weakest. Operators of one row run left to right.

Differs from JavaScript

  • &&, || and the transform | share one level: a || b && c is (a || b) && c, and a && b | f is (a && b) | f. Use parentheses. Both sides of && and || are always evaluated.
  • - before a name is an error; - belongs to a number literal only. Write 0 - Count. There is no %.
  • == compares text when either side is text (Types and conversion).
Operators Meaning
( ), ! Grouping; ! negates the operand right after it, so !a == b is (!a) == b.
*, / Multiply, divide.
+, - Add or join text, subtract.
==, !=, <, <=, >, >= Compare.
&&, \|\|, \| And, or, transform: one level.
? : Condition.
  • c ? x : y evaluates only the chosen branch. Each branch reaches as far as it can: c ? a : b | f is c ? a : (b | f), and x | f ? a : b is (x | f) ? a : b. a ? 'x' : b ? 'y' : 'z' chains.

Types and conversion

Where Rule
+ Joins text when either side is text, the other side converted; otherwise adds numbers.
-, *, /, <, <=, >, >= Numbers. Text becomes the number it starts with, or 0 ('abc' is 0); true is 1.
==, != Compare text when either side is text, else numbers: Count == '3' is true when Count is 3.
True or false (!, &&, \|\|, ? :, :if, :visible, class:*, callIf) A number is true when not 0. Text is true only when it is true or 1 in any case; other text, also a name like 'Bob', is false. An empty value is false.
Printed as text A boolean prints 1 or 0, so bEven == 'true' is false. An integer field prints as it is. Any other number, also the result of an operator, prints with at most three decimals and no trailing zeros: 1 / 3 prints 0.333, Count + 1 prints 4 when Count is 3.

Transforms

value | name(arguments) passes the value as the first argument; value | name needs no parentheses without further arguments. name(value, arguments) is the same call. A transform given the wrong arguments returns an empty value; the ones marked "logs" also write a warning.

Transform Result
to_lower, to_upper The value as text, in lower or upper case.
format(n), format(n, true) The number with n (0 to 32) digits after the point; true removes trailing zeros. A wrong argument count or precision logs a warning; a value that is not a number or a bad third argument gives an empty value silently.
round The nearest whole number; halves round up.
floor, ceil The number rounded down or up to a whole number.
abs The number without its sign.
length The number of characters of the value as text; an empty value gives 0.
arcclamp(low, high) The number limited to the range.
arcmin(other), arcmax(other) The smaller or the larger of the two numbers.
arcnum, arcnum(d) The number with digit grouping and exactly d decimals (0 to 18, default 0), in the game's language, halves to even. Text is not a number here. Logs once.
arcpct, arcpct(d) The value times 100 as a percent, in the game's language, otherwise as arcnum. Logs once.
arctime Seconds, rounded up and at least 0, as mm:ss, or h:mm:ss from one hour. Logs once.
arcplural('Key') The plural form of a String Table entry for the number (Localization). Logs once.
arcsince Seconds from the value, a time taken with ArcRmlClock::Seconds() (C++, module ArcRmlUIData, header ArcRmlClock.h), to the moment the binding is evaluated.

Event statements

A on:* holds statements separated by ;, run left to right. Each statement is a function call: call, callIf or stopPropagation (Events). A name without parentheses calls with no arguments: stopPropagation is stopPropagation(). Arguments are expressions, transforms included. The example is not from a sample: the line sits in a document inside an element whose :model names a view model, the '' in call means that model, and SetVolume is a function of it:

<input type="range" on:change="call('settings', 'SetVolume', ev.value | arcclamp(0, 1))"/>

Name = expression writes a field Blueprint may write, as :value does (Forms); a read-only field is refused with an error. Any other function name fails.

Errors

What you see, and the cause.

What you see Cause and what happens
The binding or handler does nothing; a failed {{ }} prints nothing, a failed :if or :for hides its element, a failed :visible sets visibility: hidden. When the expression parses but fails when it runs (a missing field, an unknown transform), :visible keeps the element visible on its first update and :if creates no branch. The validator reports Data expression '<expression>' does not parse: <message>. A syntax error. The document compile reports a data-expression diagnostic (Validation) in a build that is not a Shipping build; the ArcRmlValidate commandlet reports it as a warning. Documents load compiled, so the run time logs nothing: the binding or handler is not created, and the diagnostic is the only report. A Shipping build reports nothing.
A log line Could not find variable name '<address>' in data model., with the whole address (Player.Name) An unknown name. The binding is not created and shows what the row above says.
Log lines Error during execution. <message> and Failed to execute program with <n> instructions: with a dump of the program An unknown transform or event function, an assignment, or an index that is not a number. An attribute, class or style binding keeps its last value; a {{ }} prints nothing; the statements after the failing one do not run.
Nothing is logged; the value prints nothing and is false A transform given wrong arguments: the value is empty.

Messages from RmlUi appear in LogArcRmlUI, prefixed RmlUi:: RmlUi errors as errors, RmlUi warnings as warnings.