Describing a Filter: FILTER

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:


Top of page

x
Syntax: How to Declare a Filter in a Master File
FILTER  filtername = expression;

where:

filtername

Is the name assigned to the filter. The filter is internally assigned a format of I1, which cannot be changed.

expression

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.


Top of page

x
Syntax: How to Use a Master File Filter in a Request
TABLE FILE filename 
   .
   .
   .
{WHERE|IF} expression_using_filters 

where:

expression_using_filters

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.


Top of page

x
Reference: Usage Notes for Filters in a Master File


Example: Defining and Using a Master File Filter

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 SET STYLE *
type=report, style=bold, color=black, backcolor=yellow, $
type=data, backcolor=aqua, $                              
ENDSTYLE      
END

The output is:


WebFOCUS