How to: Reference: |
Boolean virtual fields (DEFINE fields that evaluate to TRUE or FALSE) can be used as record selection criteria. If the primary purpose of a virtual field is for use in record selection, you can clarify this purpose and organize virtual fields in the Master File by storing the expression using a FILTER declaration rather than a DEFINE. Filters offer the following features:
FILTER filtername = expression;
where:
Is the name assigned to the filter. The filter is internally assigned a format of I1, which cannot be changed.
Is a logical expression that evaluates to TRUE (which assigns the value 1 to the filter field) or FALSE (which assigns the value 0 to the filter field). For any other type of expression, the field becomes a standard numeric virtual field in the Master File. Dialogue Manager variables (amper variables) can be used in the filter expression in same way they are used in standard Master File DEFINEs.
TABLE FILE filename . . . {WHERE|IF} expression_using_filters
where:
Is a logical expression that references a filter. In a WHERE phrase, the logical expression can reference one or more filters and/or virtual fields.
Consider the following filter declaration added to the MOVIES Master File:
FILTER G_RATING = RATING EQ 'G' OR 'PG'; $
The following request applies the G_RATING filter:
TABLE FILE MOVIES
HEADING CENTER
"Rating G and PG"
PRINT TITLE CATEGORY RATING
WHERE G_RATING
ON TABLE SET PAGE NOPAGE
ON TABLE SET GRID OFFON TABLE HOLD FORMAT
HTMLON TABLE SET STYLE *
type=report, style=bold, color=black, backcolor=yellow, $
type=data, backcolor=aqua, $
ENDSTYLE
END
The output is:
Information Builders |