Tinderbox v10 Icon

In-text expressions

Note: this is an experimental feature, subject to change or withdrawal.

From v10.0.0, in the text pane, Edit ▸ Insert ▸ Expression adds an expression to the text, enclosed in a rounded rectangle. Clicking on the expression displays a popover which allows you to edit the expression.

From v10.1.0, the initial value of the expression is now the selected text, which the expression replaces. For example, if text '8*8' is selected inserting an Expression results in an expression element holding the code 8*8 but which in $Text displays as '64' (the action code evaluated result). If $Price is '1' and $SalesTax('tbxconfig') '0.2' (20%), then selecting '$Price+($Price*$SalesPrice)' will show as '1.2', i.e. the price paid at the counter. If either of those attributes changes the price seen in $Text will adjust accordingly.

Contrast this with Edit ▸ Insert ▸ Evaluate Selected Text, which replaces '8*8' with '64' but without an underlying stored expression. Thus in the last example above, if $Price or $SalesTax changed subsequently, the $Text would not.

For the present, expressions and checkboxes embedded in the text are ignored on export.

The expressions expected are simple ones, as in an attribute's value or some simple maths. If the expression is complicated or the desired value needs more than one expression to run, it is suggested to wrap such code in a function. An in-text expression can call the function and use the simple value it returns.


See also—notes linking to here: