Table Rules Syntax

All table rules function together to control table data and its visibility to the user, but each of the rules has a specific purpose. To apply the rules effectively, you'll need to understand the differences between them, and have a detailed knowledge of the table record structure.

Rules compare data with tables, columns, user fields, or host fields. When displayed in Presentation Designer, each of these elements is preceded by the name of its screen, which appears as the root in the Tree pane.

The following rules are specifically for use with tables:

The Last Page Rule is a host table property, specified in the Table editor. Both the Termination Rule and the Selection Rule are table control properties, specified when you bind a table control to the host table defined on the associated host screen.

Syntax

A table rule uses the following syntax:

	ScreenName.HostTable0 RuleExpression 
or
	ScreenName.ColumnName RuleExpression 

where:
        ScreenName is the name of the host screen (not the name of the form)
        HostTable0 is the name of the host table
        ColumnName is the name of a column in the host table
        RuleExpression is the expression evaluated by the rule

Tables, columns, user fields, and host fields are always referred to by the name assigned by the software, not by any user-defined header or value. Headers and values can be blank or duplicates, making their use in rule equations impossible. When a column name is used in the rule syntax, only that column of each record is checked for validity of the equation; when the table name is used, every column in every record is checked for validity.

Rules use all of the features of most scripting search methods, including wildcards (*, ?), bitwise operators (&, |, ^, ~), and mathematical operators (+, -, ==, <, >). Rule expressions can be composed of the following:

As with all Boolean equations, the statement is always valid when true.

Table Rule Examples

Last Page Rule expressions specify screen elements displayed on the last page that presents table data, as in the following sample rules:

	myHostScreenName.Hostfield0 like 'ENDOFDATA'
	myHostScreenName.Hostfield1 == '12/31/1999'
	myHostScreenName.Hostfield3 == '*A*B*C*'

In the following sample Termination Rule, all output to the table is stopped when any record is found in which at least one column is null. This could imply that an error has been discovered, or that the table has no more records to display. The record that matches the expression (in this case, a column that is null) is not displayed in the table, nor are any records following it.

	myHostScreenName.Table0 like ''

Because the table name is used, this equation is tested for validity upon each column of each record.

When used as the Selection Rule, the same expression can identify records with missing data, such as dates, tax credits, customer names, and so on. A more common use of the Selection Rule might be to locate purchases below a specified minimum purchase price:

	myHostScreenName.Column0 < minimumPurchasePrice

Because the column name is used, this expression tests only values in Column0. The display of the entire record depends only on the contents of the named column. However, since this is a Selection Rule, any record whose Column0 value does not match the equation is not displayed, and the testing of each record continues until the end of the table is reached, or the equation in the Termination Rule matches true.

The following samples apply to both the Termination Rule and the Selection Rule:

	myHostScreenName.Table0 like '*myContent*'
	myHostScreenName.Column1 == '*myContent*'
	not (myHostScreenName.Column2 == '*myContent*')
	myHostScreenName.Column3 == '*A*B*C*'
	myHostScreenName.Column0 like 'd*' AND myHostScreenName.Column1 like 'do*'
	myHostScreenName.Column4 > myHostScreenName.Column5

Rule Functions

The following list of functions can be used in rules.

Function Description Result Type
ATTRIBAT(row, col) Returns the attribute bits associated with a specified screen location.

Examples:

ATTRIBAT(1, 1) == '1172527907584'
ATTRIBAT(20, 16) == '1168231367424'
ATTRIBAT(21, 16) == '1168231105280'

Integer
COUNTMATCHES(searchStr) Returns the number of times the given string matches the screen text.

Example:

COUNTMATCHES('and') == 2

Integer
ENDCOL(searchStr, count) Returns the end column of the given string. The string can contain wildcards (like *). Count specifies the number of times the string must be matched.

Example:

ENDCOL('and', 2) == 37

Integer
ENDROW(searchStr, count) Returns the end row of the given string. The string can contain wildcards (like *). Count specifies the number of times the string must be matched.

Example:

ENDROW('and', 2) == 18

Integer
HOSTFIELDCOUNT(arg) Returns the number of actual host fields on the screen. Valid arguments are ANY, PROTECTED, and UNPROTECTED, and the argument must be within single quotes.

Example:

HOSTFIELDCOUNT('ANY') == 18

Note When the number of fields on the host screen changes, HOSTFIELDCOUNT should not be used.
Integer
IF(bool-expr, expr1, expr2) Returns expr1 if the bool-expr evaluates to true, else returns expr2.

Example:

IF((STRINGAT(21, 1, 3) == 'See'), (STRINGAT(21, 1, 8) == 'See Spot'), (STRINGAT(21, 5, 9) == 'Spot run.'))

expr1 or expr2
like Comparison operator that compares the value of a host field reference to a string (example: HostField17 like '*DIAL VTAM4*'). The string should be enclosed within single quotes. Wildcards can be used.

Example:

HostField17 like '*DIAL VTAM4*'

A Boolean TRUE or FALSE
PAGEINDEX() Returns the number of host pages specified. Because the count starts with zero, the example would display 3 pages.
Note PAGEINDEX is valid for Last Page Rule only. It cannot be used with a Termination Rule or a Selection Rule.

Example:

PAGEINDEX() == 2

Integer
STARTCOL(searchStr, count) Returns the start column of the given string. The string can contain wildcards (like *). Count specifies the number of times the string must be matched.

Example:

STARTCOL('and', 2) == 35

Integer
STARTROW(searchStr, count) Returns the start row of the given string. The string can contain wildcards (like *). Count specifies the number of times the string must be matched.

Example:

STARTROW('and', 2) == 18

Integer
STRINGAT(startRow, startCol, len) Returns the text starting at specified location and spanning the length.

Examples:

STRINGAT(21, 2, 8) == 'PASSWORD'
STRINGAT(24, 59, 11) == ' RUNNING '

String
TRIM(string) Returns string after removal of spaces in the beginning and the end.

Example:

TRIM(STRINGAT(24, 59, 11)) == 'RUNNING'

String
Related Topics
Bullet Working with Tables, Overview
Bullet Binding Host Tables to Table Controls
  Attachmate