A table object is a control that may be a child of a dialog region or dialog box. To create a table, you use the table object definition statement. With this statement, you first define the basic table attributes, then the columns in the table, and, finally the data in the rows. Once you have provided the basic definitions, you can then change most of them dynamically.
Following is an example of the definition of a simple table containing two columns and two rows:
table Simple_TBL
size 160 80 at 10 10 in Parent_DR
insert string column heading is "String"
insert integer column heading is "Integer"
insert row values "Simple Table", 1
insert row values "Another Row", 2
The following code illustrates the creation of a more complex table for an automobile dealership application. Note how it defines the basic attributes of the table, then the specific attributes of four columns (Make, Model, Year, and Price).
visible editable table CarLot_TBL
size 250 100 at 10 10 in LotParent_DR
parameter is "Sales"
helpid is BeyondHelp
horizontal scroll bar
vertical scroll bar
column delimiter is csv
column headings text
no column selection
resizeable columns
row headings blank
multiple row selection
insert string column Make
width is 60
text size 15
left align
heading is "Make of car"
insert string column Model
width is 70
text size 20
left align
heading is "Model"
insert integer column Year
width is 30
center align
heading is "Year"
insert float column Price
width is 60
right align
heading is "Asking Price"
format is "($#,##0.00)"
insert row file "Picture11-11.txt" # in CSV format
You can also add a table at runtime by using the add action statement with the same kind of definition as for a statically defined table. You can then use add to TABLE ... insert action statements to dynamically put columns and rows into the table.
The following table summarizes the attributes you can give to a table. You cannot change the attributes marked with an asterisk (*) after the table is created. See the description of the table object definition for complete details.
Attribute |
Behavior |
ancestry |
The ancestry of the table object. |
color |
Background color of the table. |
column delimiter is |
The format used when converting rows to and from text strings or files. |
column grid |
Visibility of grid lines between each column. |
column headings* |
The heading label at the top of each column. (If defined with column headings text, the text may be changed at runtime, but the type of column headings cannot be changed.) |
column selection* |
The ability of users to select multiple columns, only a single column at a time, or no columns. Either column or row selection is allowed, but not both. |
edit key |
The key used to start editing in a table (the default is F2). |
editable/readonly |
Values in editable tables can be edited. When a table is read-only, the end user cannot modify any part of the table, although the program can still change it directly. |
enabled/disabled |
Enable or disable the table. |
font* |
The font for the headings and cell contents. |
foreground |
Foreground color of the table. |
group* |
The group to which the table belongs within the dialog box or region. |
helpid |
The help panel identifier. |
horizontal scroll bar* |
Add a horizontal scroll bar. |
parameter |
The parameter string, if any, for the table. |
position |
The position of the table, in dialog units in the parent region. |
resizeable columns |
The ability of users to directly change the size of any column. |
row delimiter is |
The format used when converting multiple rows to and from text strings. |
row headings* |
The heading label at the left of every row. |
row grid |
Visibility of grid lines between rows. |
row selection* |
The ability of users to select multiple rows, only a single row at a time, or no rows. Either row or column selection are allowed, but not both. |
size |
The size of the table, in dialog units. This includes the size of scroll bars, when they are displayed. |
vertical scroll bar* |
Enable the vertical scroll bar. |
Visible/invisible |
Visible tables are shown, invisible ones are hidden. |
width is |
The width of the row heading. |