Formulas
Formulas work things out from the answers: a worked-out attribute, a component’s quantity or cost, an option’s price. Conditions are formulas that give yes or no, such as a component’s When. Templates are text with attributes in braces.
Every formula field checks what you type against the family. A problem is underlined, with a message beneath it saying what’s wrong and where, such as Unknown attribute [Drive cuont]. Did you mean [Drive count]? (at character 1). When it checks, the field shows what the formula gives and which attributes it uses. A formula with a problem never stops you pressing Save: Save takes you to it instead.
Writing a formula
Section titled “Writing a formula”- Attributes go in square brackets:
[Drive count]. Type[to choose from the family’s attributes. - Numbers are written plainly:
1200, not1,200. They’re exact decimals, so money and quantities add up. - Text goes in double quotes:
"Rack 2U". A choice is compared with one of its values by name or code:[Chassis] = "Rack 2U". A value that doesn’t exist is an error when you save. - Yes and no are
yesandno. - Upper and lower case don’t matter in keywords, function names or attribute names.
Operators
Section titled “Operators”| Operator | Meaning | Example |
|---|---|---|
+ - * / | Add, subtract, multiply, divide | [Drive count] * 12 + 150 |
= <> | Equal, not equal | [Chassis] <> "Tower" |
< <= > >= | Less than, at most, more than, at least | [Width] > 900 |
in (…), not in (…) | One of a list | [Chassis] in ("Rack 1U", "Rack 2U") |
between … and … | Within a range, ends included | [Width] between 600 and 900 |
includes, excludes | For attributes that hold several values | [Extras] includes "Spare fan" |
and, or, not | Combine conditions | [Redundant power] and not [Chassis] = "Tower" |
( ) | Group | ([Width] + 50) * 2 |
Functions
Section titled “Functions”| Function | Gives | Example |
|---|---|---|
if(condition, then, otherwise) | One of two values | if([Redundant power], 2, 1) |
min(a, b, …), max(a, b, …) | The smallest or largest | max([Drive count], 2) |
round(x, places) | Rounded to the nearest, halves away from zero; 0 places if left out | round([Power needed] / 1000, 1) |
roundup(x, step) | Up to the next multiple of the step; 1 if left out | roundup([Power needed], 50) |
rounddown(x, step) | Down to the multiple of the step; 1 if left out | rounddown([Width], 10) |
abs(x) | Without its sign | abs([Offset]) |
answered([Attribute]) | Yes once the attribute has an answer | if(answered([Drive count]), [Drive count], 0) |
lookup("Lookup", "Column") | A value from a lookup’s matching row | lookup("Power supplies", "Watts") |
Unanswered attributes
Section titled “Unanswered attributes”Until an attribute is answered, anything that uses it is unknown, not zero. A component whose quantity is unknown waits until it can be worked out, and a condition that’s unknown doesn’t apply yet. To give a value before then, test it: if(answered([Drive count]), [Drive count] * 12, 0).
Materials and cut pieces
Section titled “Materials and cut pieces”A made part’s materials use formulas per one made part. Some examples for a panel whose frame is cut from bar stock:
| Field | Formula | Gives |
|---|---|---|
| A material’s Quantity per made part | [Width] * [Height] / 1000000 * 0.2 | The litres of coating for the panel’s area |
| A cut piece’s Pieces | if([Leaves] = 2, 4, 2) | Four rails on a double, two on a single |
| A cut piece’s Length | [Height] - 40 | Each side, in the cutting unit |
| A cut piece’s Width | [Width] - 100 | A piece cut from a sheet, such as an infill |
Pieces must be whole numbers, and lengths and widths above zero. A quantity of 0 or less, or no pieces, leaves the row out, so if([Glazed], 1, 0) is another way to make a row optional.
Conditions
Section titled “Conditions”A condition gives yes or no: [Chassis] = "Tower" and [Drive count] > 4. A yes/no attribute on its own is a condition: [Redundant power]. Use brackets to group and and or: [Chassis] = "Tower" or ([Drive count] > 4 and not [Redundant power]).
Templates
Section titled “Templates”Descriptions, code templates and messages are text with attributes in braces:
| Placeholder | Gives | Example |
|---|---|---|
{Attribute} | The answer, with a number’s unit and decimals | {Memory size} gives 128 GB |
{Attribute:code} | The value’s code | RAIL-{Chassis:code} gives RAIL-2U |
{Attribute:0.0} | A number in that format | {Power needed:0} gives 450 |
Type { in a template to choose an attribute. To show a brace itself, write it twice: {{ or }}.
Limits
Section titled “Limits”A formula can be up to 2,000 characters long and nested 32 brackets deep. Something that can’t be worked out, such as a division by zero, shows as a problem on that formula rather than stopping the configuration.