DEFINE TABLE

From Recital Documentation Wiki
Revision as of 15:50, 10 November 2009 by Helengeorge (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

Define a table field in a format or program file for multiple record display


Syntax

DEFINE TABLE <table name>

FOR <.dbf filename> AS <expN> ROWS

RELATING <field> BY <key expression>

[BOXCOLOR <color>]

[COLOR <color>]

[PRETABLE <procedure name> |<expC1>]

[POSTTABLE <procedure name> |<expC2>]

[SHADOW]

[TITLE <expC3>]


See Also

@...GET, CREATE BRIDGE, CREATE SCREEN, CREATE VIEW, Function Keys, INDEX, SET FORMAT, SET RELATION


Description

The DEFINE TABLE command designates a table of multiple record based 'child' table information to be viewed on the same form with other related 'child' information and, if desired, the 'parent' table information. One to many relationships are represented and maintained in a form. As users page through records in a parent table, records in the related table fields refresh accordingly.

The tables, indexes and relational links should be created prior to issuing the DEFINE TABLE command. This may be accomplished by creating a VIEW, an APPLICATION BRIDGE, or a program file.

The number of TABLES that may be defined is limited only by the number of available workareas. The parent table for the form may have several one-to-many relationships and each table may have one-to-many relationships to other table fields. Parent records do not need to be included in the form, therefore you may build forms which contain only table fields. If a screen is to contain a parent record and a child table, the child table must be placed below the first accessible parent field.

Once you have defined all the necessary information in the DEFINE TABLES command, you need to identify the @...GET statements that belong to each table. The syntax for each @...GET belonging to a table field is:

TABLE_NAME!ALIAS->FIELDNAME

Fields included in table fields bring with them the rules defined in their respective Applications Data Dictionary settings. For example, a choice list defined for a field in the Applications Data Dictionary is still accessible from within a table field. Fields belonging to the same table are all placed on the same row.

Users may move to any of the TABLES on the screen by pressing the [NAVIGATE TABLE] key and paging through the records which are displayed. Records may be appended to any of the tables by pressing the [APPEND TABLE RECORD] key. The [TABLE AUTO APPEND] toggles automatic APPEND mode each time the [RETURN] key is pressed on the last record of the table field. The [FREEZE TABLE COLUMN] key freezes the cursor within a specific column. A key usage pop-up window displays when the user presses the [TAB] key. The [ABANDON] key backs the user out of the table fields. When used with a manual READ, table fields are read-only, and cannot be navigated as described above.

Table fields may also be created in the Forms Designer. See the CREATE SCREEN command for full details.

<table name>

Each table field is distinguished by a unique <table name> qualifier. The <table name> must start with a letter or underscore and can consist of letters, underscores and digits (0-9). The <table name> must not exceed ten characters.

FOR <.dbf filename>

The FOR clause specifies the name of the 'child' table, <.dbf filename>, from which the records should be displayed.

AS <expN> ROWS

The numeric expression <expN> states the number of rows, or records, to display in the TABLE.

RELATING <field> BY <key expression>

The RELATING clause specifies the relationship between the 'parent' and the 'child' tables. This is in addition to the SET RELATION command, not instead of it. The <field> is the name of the field in the 'child' table. The 'child' table must be indexed on this field and this must be the master index order. This field must also exist in the 'parent' table and is the basis of the relationship between the two tables. The <key expression> consists of the name of the 'parent' table, plus the alias pointer (-> or .), plus the name of the matching <field> in the 'parent' table.

BOXCOLOR <color> COLOR <color>

By default, the table will be the color of FIELDS and the box will be the color of BOXES. The optional COLOR and BOXCOLOR commands specify alternate colors for the table and the box, respectively. A TITLE <expC> must be specified for the box to be displayed. Assigned colors take the form: foreground/background, and are set using the following letter codes:


Color Attribute Code
BLACK N or blank
BLUE B
GREEN G
CYAN BG
BLANK X
GREY N+
RED R
MAGENTA RB
BROWN GR
YELLOW GR+
WHITE W


PRETABLE <expC1> POSTTABLE <expC2>

The optional PRETABLE and POSTTABLE keywords associate trigger procedures with the entry and exit of the table field. The READVAR() function is useful within trigger procedures as it returns a blank when the table is displayed, and the table name when the table is activated.. The procedure names may be specified with character expressions <expC> that return the names of valid trigger procedures.

SHADOW

The SHADOW keyword causes a shadow to display along the right and bottom edges of the box. A TITLE <expC> must be specified for the box to be displayed.

TITLE <expC3>

The TITLE option is used to specify field or column headings for the table. If the TITLE option is used, a box will be drawn around the fields and the headings. The TITLE character expression must contain column headings, separated by commas, for every field in the table.


Example

define table acc;
  for accounts;
  as 7 rows;
  title 'Pd#,Ord#,Date,Price,Received,Paid,Payment,Balance';
  posttable order_posttrig;
  relating account_no by customer->account_no
set preform to orderspreform
set postform to orderspostform
set prerecord to orders_prerec
@01,00 to 06,79
@02,01 say [Account code]
@02,18 get customer->account_no
@02,25 say [Start Date]
@02,36 get customer->start_date
@03,01 say [Customer Name]
@03,18 get customer->title
@03,22 get customer->first_name
@03,33 get customer->initial
@03,36 get customer->last_name
@04,01 say [Street]
@04,18 get customer->street
@05,01 say [City]
@05,18 get customer->city
@05,30 say [,]
@05,31 get customer->state
@05,34 get customer->zip
@10,01 get acc!accounts->product_no
@10,06 get acc!accounts->ord_no;
  picture [@S4X]
@10,11 get acc!accounts->ord_date
@10,22 get acc!accounts->ord_value
@10,34 get acc!accounts->rec_date
@10,45 get acc!accounts->paid_date
@10,56 get acc!accounts->paid_value
@10,68 get acc!accounts->balance
@18,00 to 20,79
@19,01 say [Total:]
@19,13 get m->m_orders;
  picture [99999999];
  when .f.
@19,22 get m->m_ord_val;
  picture [$$$$,$$9.99];
  when .f.
@19,56 get m->m_paid_val;
  picture [$$$$,$$9.99];
  when .f.
@19,68 get m->m_balance;
  picture [$$$$,$$9.99];
  when .f.
 
// Open demo.dbf bridge.
// This opens the four demo tables and sets up
// indexes, relations and format files
use demo
edit


Products

Recital