A lookup table is a collection of objects which are stored under individual keys to access them.
A pair of key and value (the object to store) in a lookup table is named "element". A key can only be used by one element in a lookup table. A special value in contrary can be contained in many elements if it is stored under differing keys.
To read the value of an element from the table use table.get with the key of the element. To create or update an element with a new value use table.put with key and value as parameters.
Keys and values of a lookup table may technically be any type of object, but mostly trivial objects like strings or numbers are used as they can be easily compared and recreated. String keys are case sensitive. You can store different elements under keys "Key", "key" and "KEY".
To iterate over all existing elements of a table you can use global function WGA.getLookupKeys() to retrieve all its keys, which you then can use to retrieve all element values.
From a Java perspective lookup tables are just the TMLScript view of Java interface java.util.Map
Via many methods, but mainly by:
|Allowed in script types||
|Properties and methods||
This example creates a table and fills it with month numbers as keys, storing the corresponding month name as values:
months = WGA.createLookupTable();
Such a table could be used in WebTML code to lookup month names for numbers (not that these couldn't be automatically generated by date formatting, so this is just for demonstration purposes ;-):
The month is <tml:script expression="months.get(monthnr)"/>