The last enhancement needed to our decode of the Set Actuator command is to make the command_code field show the name of the command rather that just the hex value. That way the Summary and Decode panes will be easily readable as in the example above, where you can quickly scan down the Command/Response column and see what commands have been issued.
We use a Format Method called Table to accomplish this. At this point you may ponder and say, "I thought Table was a section within a decoder script. That is what it says in The Table Section." This is true, table is indeed a section within the decoder script. However, Table is also a Format Method. We will explain.
Table uses a field value to index a table of strings. In effect, the Table Method acts as a pointer to a table within the Table Section. Tables are placed at the top of the decoder, right below the DECODE keyword and before any FIELD statements.
Here is an example that defines a table of FP commands:
TABLE tableCommands
{ 0 "Request Status" "Request Status"}
{ 1 "Set Actuator" "Set Actuator"}
{ 2 "Read Sensor" "Read Sensor"}
{ Default "???" "(unknown)"}
ENDTABLE
This is a DecoderScript representation of the list of FP commands given at the start of this chapter. Each entry starts with a number that corresponds to a command code except for the last in which the keyword "Default" tags a special entry that serves as a catchall for any values for which there are no explicit entries. The number can be decimal or hexadecimal. Two strings follow. The first is for display in the Summary Pane while the second is for the Decode Pane. In our table these two strings are the same for each entry other than the default. The value of having two distinct strings, one for each pane, is that you frequently want to display an abbreviated description in the Summary Pane (where space is tight) and a fuller description in the Decode Pane.