This version is out of date, covering development from v7.0.0 to v7.5.6. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox 7 Icon

Look-up tables

Look-up tables allow simple value arrays. This lets some discrete values be mapped onto other values. For example, suppose some notes record the state in which each customer resides. Each state is assigned to a region and it is useful to know the sales region for given customer. Previously, a usual approach would be a set of if() statements:

if($State=="AL") { $Region = "South";} 

However, this is a tedious process if there are many states - it needs a lot of if() statements.

Instead, for a Set, List, or String type of Attribute create a list of key/value pairs, separated by colons. Each colon-separated pair is then delimited from then next pair by a semi-colon as with a normal Tinderbox list - a semi-colon is not needed after the last pair. Thus:



Optionally a default value (for keys with no match) can be defined:



Keys should not consist of numbers only as this may confuse Tinderbox. Should you need to use numbered keys, perhaps because you are generating the look-up key based on a computed value, place a letter before the number. So, use 'x1' rather than just '1'.

Look-up tables allow actions like:


If the set does not contain the key value, .at() looks for an optional special default key ('default') and returns that key's value; if there is no default value defined or it defined with no value, .at() returns an empty string.

Realistically, if using lookup tables the lookup value list will be defined in one note and then referenced by all others. Thus the last example above is more likely:


Lookup tables are able to specify several keys that map to a common value. This is done by separating each key with the pipe character '|'. For example:


A structural representation of the above example is as follows. The first key/value set is in normal text, the second in italics, the third in bold, the default in plain text:


The number of keys in each Key/Value set is discrete from other sets in the list.

Keys are matched on exact, case-sensitive, strings. In the above example "Tess" will return "Hardy" but "tess", "Tes" or "Tessa" would return "anon". If no default had been defined, an empty string "" would be returned instead for the non-matching values.