Expressions are formulas made of raw numbers or strings, variables, or expression functions. They may also include mathematical or logical operations. Every expression is evaluated during template processing, and the result is always a single value.
In numerical expressions, you can use the following operators:
Addition | + |
Subtraction | - |
Multiplication | * |
Division | / |
Modulo (remainder): | % |
In logical expressions, you can use the following operators:
Negation | ! |
Conjunction (and) | && |
Disjunction (or) | || |
Comparison | <, <=, ==, >=, > |
The order of evaluation follows standard mathematical priority (PEMDAS). For example, 10+displayScale*3 is equivalent to 10+(displayScale*3).
Working with Expressions
Expressions can be combined and applied in different ways. The following examples show how they appear in practice:
Raw string: "Text"
Raw number: 3.58
Variable of type STRING: modelName
Expression function (numeric result): Max(displayScale, 1)
Numerical expression with a function and an operation: (Max(displayScale, 1) + 3.5)
Logical expression comparing two numerical values: (Max(displayScale, 1) + 3.5) > 10
Logical expression comparing two string values: modelName == "Model 1"
Logical expression combining multiple conditions: ((Max(displayScale, 1) + 3.5) > 10) && (modelName == "Model 1")
Expressions can be used in text output or as parameters to functions:
To output a value directly into text: $(expression)
To provide values as parameters to a function: $FunctionName(expression, expression, ..., expression, some text)
Example: $If( !modelIsTextured, Model is not textured. )
If the model is textured, the result is an empty string.
If the model is not textured, the result is: Model is not textured.