Skip to main content

Module resolve

Module resolve 

Source
Expand description

Macro tokens: references in step parameters that are worked out when the step runs, so a macro made on one block of data works on another.

A token is a base followed by methods:

  • bases: a declared input (Input, Rates), Output (the output rule’s anchor), Row or Column (the current item of the Repeat step around it), and Name:Total (a defined name or a table’s data; a name can hold periods, and the longest one that exists is used, so Name:Sales.Q1.cell(1,1) is a cell of Sales.Q1);
  • methods, 1-based and chainable: .col(n) or .col("Amount") (by an input’s header row, also after .data), .row(n), .cols(a..b), .rows(a..), .cell(r,c) (relative to the top-left cell; any whole numbers, so cell(0,1) is the cell above), .offset(r,c), .resize(h,w), .data (without the header row), .below(n) and .right(n) (the n rows below or columns right of the range).

In parameters a token is written three ways: {"$ref": "Input.col(2)"} anywhere; the whole string "Input.col(2)" in a reference parameter (cell, range, target, to, keys ending in Cell or Range…); or {{Input.col(2)}} inside any string ("=SUM({{Input.col(2)}})"). Each becomes A1 text before the command runs, so commands never see a token. Text that would read as a token is written {"$text": "Output"}: it is passed as it is, never resolved or interpolated (a defined name called Output, or Dear {{name}}). Plain A1 references in steps are absolute: they don’t follow row inserts (as in VBA); a Name: anchor does.

Structs§

Env
What tokens refer to while a step runs.
Place
A resolved reference: a block of cells on a sheet.

Enums§

ResolveError
Why a reference couldn’t be worked out.

Functions§

a1
place as A1 text, with the sheet name when it isn’t the active sheet.
interpolate
Replaces each {{token}} in s. {{{{ is a literal {{, for text that needs the braces themselves ("Dear {{{{name}}" writes Dear {{name}}).
is_ref_key
Whether a parameter called key holds a reference.
is_token
Whether text starts like a token (its base is one this environment knows). A reference on a sheet with such a name (Output!A1) is not a token.
quote_sheet
Sheet1 or 'My Sheet' (quotes doubled).
reads_as_token
Whether text would read as a token in a macro whose inputs are inputs (see is_token).
resolve_params
Step parameters with every token replaced by A1 text.
resolve_ref
Resolves a token, or a plain reference (B2, Sheet2!A1:C3, a defined name).
resolve_token
Resolves a token (see the module docs).