Expressions
Note: Most designs never touch custom expressions. Skip this page unless you are building CAM outline macros or a highly specialised cut that needs custom math.
Expressions are the pieces that fit inside statements: numbers, point helpers, comparisons, and function calls. If you can read a simple calculator formula, you already know most of what you need.
Numbers, booleans, and strings
- Numbers accept decimals and scientific notation (
42,0.18,1.5e-2). - Booleans are just
trueandfalse. - Strings live inside double quotes and support escapes like
\"and\n. You will mostly see them inset nameor macro bodies.
Optimizable numbers use square brackets—[41.8, 38, 44, "pavilion-angle"]—to record a starting value, optional minimum/maximum bounds, and an optional label that shows up in the optimizer. Commas separate the items; you can stop after the value, or add one, two, or three extra entries.
Operator rhythm
FSL follows the same order of operations you learned in school:
- Negation and logical NOT (
-depth,!flag) - Multiplication, division, modulo (
depth / 2) - Addition and subtraction (
angle + 2) - Comparisons (
<=,>=,<,>,==,!=) - Logical AND/OR (
&&,||) - Function calls (
sin(angle))
Parentheses always win when you want to override the default order.
Handy functions
Call functions by name with parentheses. The most common helpers are:
sin,cos,tan,asin,acos,atan,atan2deg2rad,rad2degsqrt,abs,log,log10,floor
You can also read the current gear with the built-in constant GEAR.
Point helpers
Point helpers return locations in space and slot neatly into facet commands or variables. Store them with let point = mp(G1) and reuse as often as you like. The edge(...) helper is the lone exception: it returns two points, so you must destructure it (let left, right = edge(P1:0, P1:12)) instead of assigning the whole edge to a single identifier. When you need deeper explanations or syntax variations, head to the dedicated Point Helper Reference for cp, gp, mp, ep, fred, prz, edge, and the at attachment clause.
Everything in motion
Paste this snippet into the studio to see several expression types working together:
set name "Expression Tour"
set gear 96
P1 0 @ 41.8 : 0.18 x8
P2 6 @ 39.4 : mp(P1)
P3 12 @ (39.4 - 1.2) : [0.18 - abs(-0.02), 0.14, 0.22]
let shoulder = mp(P3) at (12, 39.4)
show down shoulder green
G1 0 @ 90 : size x16
G2 0 @ 90 : mp(G1) x16
let table = mp(G1)
show table magenta
C1 0 @ deg2rad(rad2deg(32.0) + 0.2) : table + girdle
C2 0 : 28.0 : ep(edge(C1:0, C1:6), 0.5)
Try editing the expressions—change the angles, adjust the math—and watch the viewer and analyzer respond immediately. Once you are comfortable, move on to Macros & Reuse to package these ideas for repeated use.