A lookup table's capabilities are driven by its lookup entries. Each and every entry defines a comparison test to be performed on a specific input parameter value. For example, suppose a lookup table defines an integer input parameter named "Hour" and contains an entry that refers to said input parameter. If the entry's comparison test is "greater than or equal to 7", this means that the entry is deemed to be matched whenever it is presented with a set of input parameter values that include one named "Hour" with a corresponding integer value of 7 or higher.
A lookup entry may itself contain lookup entries. It may also define a set of output parameter values. If it does, the lookup table may return these values if the entry is matched with an input parameter value. Whether it will return them depends on whether the entry contains a child entry that also matches an input parameter value. In all instances, though, an entry can only be a match-candidate if both it and all of its ancestors satisfy their comparison tests.
Use the
Lookup Table toolbar to add lookup entries to the list. A new entry is also added automatically (and placed in
edit mode) when you press Return or Enter while editing the last lookup entry in the list. (This behaviour makes it easy to work solely with the keyboard.)
To edit a lookup entry, select it and click it to put it into edit mode. Alternatively, press Return or Enter and the selected entry will enter edit mode. To commit changes, press Return or Enter again. To cancel, press Esc. The Tab key cycles keyboard focus over the editable fields and, in conjunction with the Shift key, works in reverse too. Any lookup entry can be relocated by using the
Node Hierarchy toolbar buttons or the relevant context menu items. Entries may also be cut, copied, pasted and deleted.
When a lookup operation is performed on a lookup table, each entry is tested in turn. Where an entry matches the incoming data, the entry's children are then tested (if there are any). When an entry is matched that defines a set of output parameter values, only its child entries are subsequently tested: if none of these child entries can be matched then the aforementioned output parameter values are returned by the lookup table and no further entry-testing takes place.
Example 1
In the above screenshot the lookup entries belong to a lookup table that serves to determine whether a specific hour of a specific day constitutes a rush-hour period. The entries are such that if an input parameter value for "Day" is 0 then the lookup table will return a RushHour value of "False". This is because:
-
the row-1 lookup entry's comparison test is passed;
-
said lookup entry defines an output parameter value, this being "False";
-
said lookup entry has no children to test.
Example 2
Now suppose that an input parameter set is presented to the lookup table that contains a value of 3 for "Day". The lookup table will return a RushHour value of "False". This is because:
-
the row-1 lookup entry's comparison test fails, so the next sibling is tested;
-
the row-2 lookup entry's comparison test is passed;
-
said lookup entry defines an output parameter value, this being "False";
-
said lookup entry has two children to test but the absence of an "Hour" value in the input parameter set means that both tests fail.
Example 3
This time an input parameter set is presented that contains a value of 4 for "Day" and a value of 17 for "Hour". The lookup table will return a RushHour value of "True". This is because:
-
the row-2 lookup entry's comparison test is passed;
-
the comparison test of the second child of said lookup entry (row 4) is passed;
-
said lookup entry defines an output parameter value, this being "True";
-
said lookup entry has no children to test.
Example 4
This time an input parameter set is presented that contains a value of 6 for "Day" and a value of 10 for "Hour". The lookup table will return a RushHour value of "False". This is because:
-
the row-1 and row-2 lookup entries' comparison tests fail, so the next sibling (row 5) is tested;
-
rows 3 and 4 are ignored because they are children of an entry (row 2) for which the comparison test failed;
-
the row-5 lookup entry's comparison test is passed;
-
said lookup entry defines an output parameter value, this being "False";
-
said lookup entry has no children to test;
-
in this case the "Hour" input value proves redundant.
Example 5
Finally, an input parameter set is presented that contains a value of 39 for "Day". The lookup table will return no match. This is because:
-
none of the rows' comparison tests is passed;
-
the lookup table itself does not define a default value.
A refinement
The lookup table used in these examples can be refined, as shown
here.