TABLE: Data Screen Formatting Compiler

Contents

Introduction

Table is a tool for generating .fld files which can be used by the ARP Data Acquisition System to display realtime data in text formats on a QNX console. Table provides an alternative to either using scrdes or editting .fld files by hand with a text editor.

Data screens are often made up of multiple small subtables, each grouping together related data items. When developing a screen layout, the size of each subtable is often not known early on. As a result, the relative positioning of the tables on the screen cannot be determined until the smaller tables are defined. With Table, you can define each subtable separately, then combine them in a variety of ways, viewing the results in order to determine the optimal organization.

Table supports the organization of data into columns and allows the use of attributes and the PC line-drawing characters to help annotate your tables. The syntax of table is designed to provide the most common formatting options with the simplest syntax possible.

Table source code is stored in a file with the extension ".tbl". Appgen will generate commands to translate this file into a ".fld" file using the table compiler.

For the purposes of getting familiar with table, you can run the table compiler yourself by hand; if you place your table source code in a file named test.tbl, you can generate test.fld with the command:

        table test.tbl >test.fld
You can then view the results using scrpaint:
        scrpaint test.fld
You may wish to use scrdes to create a configuration file test.cfg with suitable color attributes for the generated screen also.

Tables

Tables are the basic element of a table definition. Here is a simple table definition:
        { "Text on line 1";
          Line2: ;
          "Line 3"
        }
Some things to notice are:

Words

In order to use a word without quotes, it must begin with a letter or one of the characters '_', '%' or ':' and contain only these characters or numbers. It must also not match one of the table keywords.

When more than one word appears on a line, table arranges the output into columns:

        { Col1: Col2;
           A     B;
           C     D;
        }
Multiple words can be treated as a single word by enclosing the words in quotation marks (""). A single word by itself on a line of a table is not treated as part of the first column; it essentially spans all the columns. This is useful for adding titles to a table:
        { "Table with Columns";
           A   B   C   D   E;
           F   G   H   I   J;
        }

Data Fields

In addition to titles and labels, a data screen layout must specify where the actual data will appear. Data fields are specified with the syntax:
(mnemonic[,width[,height]])
where mnemonic is the name of the datum, width is the width in characters and height is the height in rows. Width and height are optional and default to 5 characters wide and 1 row high:
        { "Lamp Module";
          A_UVV: (A_UVV,5) V;
          A_IRV: (A_IRV,5) V;
          A_LMT: (A_LMT,6) C;
        }
When data fields are arranged in a column, they are right-justified within the column. Labels are left-justified within columns. It is possible to alter this justification scheme by several means for special cases, but this seems to be the "right thing" in most cases.

HBoxes

Tables are handy for listing items vertically and in columns. HBoxes provide a means for arranging items horizontally. Compared to tables, HBoxes are pretty simple: items within an HBox are separated by semicolons and arranged horizontally on output. No additional spacing is provided, as is the case with columns.
        HBox { anti; dis; establishment; arianism }

Lines and Boxes

Lines can be added to a table with the following symbols:

The following table will have dividing lines above, below and between the A and B sections:

        { -;
          A_UVV: (A_UVV,5);
          A_IRV: (A_IRV,5);
          -;
          B_UVV: (B_UVV,5);
          B_IRV: (B_IRV,5);
          -;
        }
To form an enclosing box, you must nest a table inside an HBox (or vice versa):
        HBox {
          |;
          { -;
            A_UVV: (A_UVV,5);
            -;
          };
          |;
        }
The line-drawing symbols may have a '+' symbol before and/or after it to indicate that the line should be extended to connect to neighboring lines. A '+' before or after a horizontal line symbol extends the line to the left or right, respectively. A '+' before or after a vertical line symbol extends the line up or down.

In the previous example, the box would not actually be closed. The horizontal lines in the nested table need to be extended to meet the enclosing vertical lines. This is accomplished by replacing the '-' symbols with the string '+-+'.

Named Tables

A valid table definition contains a single top-level table definition which may include nested tables and HBoxes. Building several subtables and HBoxes into a bigger table can become rather unwieldy, particularly when you are trying to rearrange the subtables. Some amount of modularity can be achieved through the use of named tables.

A named table is a table which is defined before the main table definition which has a name associated with it:

        LampA {
          HBox{ +-; "Lamp A"; -+; };
          A_UVV: (A_UVV,5);
          A_IRV: (A_IRV,5);
        }
The named table can then be referenced within other tables by enclosing the table's name in square brackets ([]):
        { HBox { |; [LampA]; |; [LampB]; | } }

Justification

By default, labels and titles are left-justified and data fields are right-justified. The '>' and '<' symbols can be used to alter this. '>' before a word serves to "push" the word to the right. '<' after a word serves to push it to the left. With both, the word is centered:
        { >"Lamp A"<;
          A_UVV: (A_UVV,5);
        }
Note that the horizontal line-drawing characters have the same effect, except that the space is filled with a line. In most cases you will want to use one or the other, not both.

Attributes

Attributes are used to specify the color of different elements of the screen display. Within the .fld file format, and hence within table itself, you don't actually assign a color to an item, but rather a color code, which is a small integer. Later, each small integer is mapped to a particular color combination. The specific colors are recorded in a .cfg file, which can be generated by the scrdes utility. Multiple .cfg files can be used with the same .fld file in order to create different color combinations. This is useful when a data screen may be viewed either on a color display or on a monochrome display, for example. I often use a special .cfg file which highlights the data field locations when I am designing a screen.

By default, text uses attribute value 4 ("LABEL"), data fields use attribute value 2 ("FIELD") and line-drawing characters use attribute value 1 ("BOX"). The keyword "Title:" switches the current text attribute to 5 ("TITLE"), and the keyword "Header:" switches the attribute to 3 ("HEADER"). You can also switch to an explicit attribute number, n, by specifying "Attr n".

The new attribute value remains in effect until another attribute is specified or until the end of the current table row or the current HBox.

Overlay

Under certain restricted circumstances, it is useful to specify that more than one data field appear at a single location. The Overlay construct allows this:
        Overlay { (%TMA:Flightalgo:1,0+1,2) (%TMA:Labalgo:1,0+1,2) }
This is useful in the case where only one of the data fields will be used at a time. In the example, only one of Flightalgo or Labalgo will be used at a time, so the status information can be located in the same position.

Glue

Glue allows for more explicit control over spacing in certain circumstances. Based on TeX's glue concept, glue dimensions can be specified with two components, known as space and stretch. Space is the normal number of spaces or rows the item requires, while stretch is a scaling factor indicating by what proportion the item should grow if there is space available. When laying out a table, all the space and stretch components are added together. If more space is available than required by the sum of the space components, the remaining space is divided up proportionally among the items based on their stretch components. (For more information, see Knuth, "The TeXBook").

Glue dimensions are specified either as a single integer, if there is no stretch component, or as two integers separated by a '+' symbol, e.g. 3+1, indicating 3 spaces plus 1 stretch.

You may use glue dimensions when specifying the width or height of data fields. You can also insert glue explicitly into a table or HBox by using either the HGlue or VGlue commands. VGlue is used in the example below to center the data vertically within the available space.

        { VGlue 0+1;
          -;
          Center: (data,3);
          -;
          VGlue 0+1;
        }

Appendix

Grammar

This grammar is specified using Extended Backus Naur Form (EBNF) as used by the Eli Compiler Construction System. Each statement describes a "production". The item to the left of the colon is a non-terminal symbol. Its instance on the right hand side of any production can be replaced by symbols matching the right hand side of any of its production rules. Literal text which appears in a program is specified as a single-quoted string ( 'Table' ). An optional item is enclosed in square brackets ( [ 'Table' ] ). An asterisk (*) following an item indicates that it may occur zero or more times. A plus symbol (+) following an item indicates that it may occur one or more times. The slash character (/) is used to indicate that the production can use one of two or more alternatives. For example, in the definition:
             Glue : HGlue / VGlue .
Glue can be either HGlue or VGlue (not both). Productions are terminated by a period (.).


Program : NamedTable* Table .

NamedTable : BareWord Table .

Table : [ 'Table' ] '{' TableDefs '}' .
TableDefs : / TDunterminated [ ';' ] .
TDunterminated : VField / TDunterminated ';' VField .

HBox : 'HBox' '{' HBFields '}' .
HBFields : / HBunterminated [ ';' ] .
HBunterminated : HField / HBunterminated ';' HField .

VField : GAField / Columns .
CField : GAField .
HField : GAField .
Columns : CField CField+ .
GAField : [ Attr ] GField .
Attr :
	'Title:' /
	'Header:' /
	'Attr' Integer .
GField :
	Table /
	HBox /
	TableRef /
	Align /
	HWord /
	Datum /
	Rule /
	Overlay /
	Glue .

AField :
	Table /
	HBox /
	TableRef /
	HWord /
	Datum /
	Overlay /
	Rule .

TableRef : '[' BareWord ']' .

Align : LeftAlign HAField RightAlign .
HAField : AField .
LeftAlign : LeftAlignChar+ .
RightAlign : RightAlignChar* .
LeftAlignChar : '>' .
RightAlignChar : '<' .

HWord : Word .
Datum : '(' Word DatumDimensions ')' .
DatumDimensions :
	/
	',' Dimension /
	',' Dimension ',' Dimension  .
Word :
	BareWord /
	CString .

Glue : HGlue / VGlue .
HGlue : 'HGlue' Dimension .
VGlue : 'VGlue' Dimension .
Dimension : Space [ GlueSpec ] .
Space : Integer .
GlueSpec : '+' Integer .

Rule : RuleString .

Syntax

The following are the low-level definitions for the syntactical elements of the table grammar:
BareWord
any word matching the regular expression [A-Za-z_%:][A-Za-z0-9_%:]* and not matching any of the reserved keywords.
CString
A C-style string constant using double-quotes (""). May include spaces.
Integer
A C-style integer, including the octal (0377) and hex (0xFF) prefixes.
RuleString
String matching the regular expression \+?(([-=])|(\|\|?))\+? See the section on Rules for a more illuminating description.
Comments
May be either C-style ( /* comment */ ) or awk/sh-style (beginning with a '#' and continuing until the end of the current line ).

Keywords

The following words are reserved. They must be quoted if you want their text to appear on your screen:


Return to Manuals Guide


last updated: Thu Jan 2 10:56:36 2003 webmaster@huarp.harvard.edu
Copyright 2004 by the President and Fellows of Harvard College