Reference · Syntax

Formula syntax

Overview

Write formulas to calculate prices or validate restrictions using simple math and logic. Variables are referenced with @variable and are case-insensitive (e.g., @Width equals @width). Number variations in inches hold total inches as a plain number (63 means 5′3″).

Variables

  • Use @name to reference a variable, for example @width.
  • Text variables compare with strings using 'single' or "double" quotes.
  • Variables are case-insensitive: @Color == @color.

Operators & Precedence

From tightest to loosest binding:

( ) and function calls → unary - ! → ** (power, right-associative) → * / % → + - & → < <= > >= → == != → && → || → ? :

& joins text ('W' & @width); + also joins when either side is text.

Functions

Call a function by its bare name followed by parentheses; separate arguments with commas. Names are case-insensitive (MAX( works). A name with @ is always a variable, so a variable called min is still @min.

  • min(a, b, …) / max(a, b, …) - smallest / largest value
  • floor(x) / ceil(x) - round down / up
  • round(x) - nearest whole number; halves round away from zero (round(2.5) is 3, round(-2.5) is -3)
  • abs(x) - absolute value
  • clamp(x, lo, hi) - x limited to lo…hi (lo must not exceed hi)

No other functions exist (no sqrt, sin, log, if(…)) - use ** for powers and ? : for conditions.

Conditionals

Use the ternary operator: condition ? value_if_true : value_if_false. Combine conditions with && (and), || (or) and ! (not).

String Comparisons

Compare text variables with == or !=. Example: @color == 'red' ? 10 : 0

Examples

Price based on width (inches):

@width > 10 ? 100 : 50

Add 15% if color is premium:

@color == 'gold' ? 1000 * 1.15 : 1000

Charge $4 per inch over 96, never below zero:

max(@width - 96, 0) * 4

Restriction (must be true/false), width in inches:

@quantity >= 1 && @width <= 120

Notes

  • Use ** for power: 2 ** 3. ^ is not supported.
  • Use &&, || and ! for logic (not the words and/or/not), and == to compare (a single = is an error).
  • Any character outside this syntax (for example ^, $, #, [ ]) is reported as an error with its position - it is never silently ignored.
  • Formulas should evaluate to a number (price) or boolean (restriction).
  • Avoid division by zero or results that are Infinity/NaN.