Code mode: one script for the whole configurator — gull system handbook
Code mode (the Logic add-on) in gull system: a JavaScript script, inputs and return, unit settings, what a script may not do, limits and messages.
Code mode: one script for the whole configurator
With the Logic add-on one JavaScript script replaces the formulas: it reads the inputs and returns the parameter values. It suits a calculation with loops, arrays or more steps than fit in a formula.
Switch it on
In step 3, in the ribbon's Evaluation group click Code and confirm Change. The formulas stay saved and are simply not used; switching back works the same way.
The shape of a script
- Read an input as `vstupy["Length"]` (alias `inputs`).
- The script must end with `return { "parameter name": value, … }` — the keys are the names of the captured parameters from step 1. The Parameters panel next to the editor shows every target with its key and a preview value.
- The editor's example: `const d = vstupy["Length"]; return { "Length": d, "Hole": d > 2000 };`
- `Math` and `console.log`, `console.warn`, `console.error` are available; their output appears under the editor.
Settings
- Row: Lengths in - Values: mm, cm, m - Meaning: the units the script computes in; converted for the model
- Row: Angles in - Values: °, rad - Meaning: the same for angles
- Row: Decimal number in inputs - Values: "1.25 and 1,25", "1.25", "1,25" - Meaning: how a value arriving from a form or Excel is read — not how you write code
- Row: Load from file - Values: .js or .txt - Meaning: copies the file's content once; the file is not linked afterwards
What a script may not do
- `Date` and `Math.random()` are refused: "a rule must give the same result every time". A date for the order comes from the workflow's Value node.
- No file or network access.
- It cannot see Library tables yet — the `tabulky` object is empty.
- Code uses a decimal point: "JavaScript has no decimal comma — write 1234.5, not 1234,5".
Limits and messages
A script may run for 2 s, create arrays up to 10 million items and recurse only so deep; exceeding that stops the order with "an endless loop?". A script returning names no parameter has gets a warning in the editor already.
Suppression in a script follows the old convention: `true` or a non-zero number = suppress, the opposite of formulas. The texts `"S"` (suppress) and `"U"` (active) mean the same in both modes — use them so you never have to think about which mode you are in.
The preview in Code mode does not write to the model, unlike formulas. You see a script's result on an order or in the Parameters panel.