Use this file to discover all available pages before exploring further.
penscript supports local variable definitions, deferred evaluation, and value pipelines. These operators let you break complex expressions into readable parts, build reusable templates, and chain transformations step by step.
Defines local variables that are available only within the :in expression. Variables can reference each other sequentially — each definition can use variables defined before it.
Creates local variable bindings directly within an expression — typically inside a :map. The first argument defines the variables, the second is the expression that uses them.
{ ":with": [ { "pos": { ":sum": ["{@index}", 1] } }, { "title": "Person {pos}" } ]}// Inside a :map where @index is 0:// Result: { "title": "Person 1" }
The difference from :define/:in: :with is designed for use inside loops and transformations where you need a quick local binding without a full :define block.Generating complex dynamic structures:
Captures an expression without evaluating it. The result is the expression structure itself (the AST), not the evaluated value. This is the foundation for building reusable expression templates.
Evaluates an expression that was previously captured with :raw or built dynamically. This is the counterpart to :raw — it takes a stored expression and runs it in the current scope.Simple evaluation:
{ ":eval": { ":sum": [1, 2, 3] } }// Result: 6
Combined with :raw for reusable templates:
{ ":using": { "duplicateInArray": { ":raw": ["{a}", "{a}"] } }, ":eval": "{duplicateInArray}"}// Scope: { "a": 7 }//// Evaluation steps:// 1. "duplicateInArray" is defined as a raw expression ["{a}", "{a}"]// 2. :eval resolves "{duplicateInArray}" to that raw expression// 3. The raw expression is evaluated in a child scope where "a" is 7//// Result: [7, 7]
The :using operator defines named expressions — like :define, but specifically designed for storing expression templates that :eval will run.
Pipelines are useful when a value needs to pass through a series of transformations — adding fees, applying tax rates, rounding — where each step depends on the result of the previous one. The @value context variable always contains the output of the most recent step.