Go to the first, previous, next, last section, table of contents.


FILTER

Use this macro to define how to filter the records (restrict the output) in the master database file. By default no filtering is done. There is a maximum number of filter conditions, which can either be given as multiple arguments to this macro or this macro can be used more than once. Each filter condition given as a multiple argument to one predefined macro is or'ed together. Each predefined macro call is and'ed with any others. Each filter condition is given as a string argument. Only records matching the given conditions will be processed. A record is written out if it matches at least one of the or'ed filter conditions from all of the and'ed filter conditions.

The filter condition has the syntax field=re. The field is the name of a database field, including the % character identifier. The re is a regular expression with the same syntax as used in the UNIX ed(1) and sed(1) commands. There should be no spaces in the condition unless they are required in the regular expression. There is an example program fragment below with some filter conditions defined.

%%FILTER "%STATUS=ENDED" "%STATUS=FAILED"
%%FILTER "%YEAR=199[123]"

The above would write out all records that have a STATUS field of ENDED or FAILED and have a YEAR field with the value 1991, 1992, or 1993.

You can define a filter condition that is an equate rather than a regular expression by using the special field name %_EQ. The equate expression should return a boolean, numeric, date, or string type. The filter condition matches if the number or boolean is not 0 or the date or string is not empty. The two filters conditions given below are identical. See section EQUATE for details of equate expression syntax. Note that the equate must be a reversed equate expression, it will not currently be auto reversed if it is not and keywords will not be recognised. Nested string quotes must be escaped within a filter condition.

%%FILTER "%STATUS=ENDED"
%%FILTER "%_EQ=%STATUS\"ENDED\"="

Beware of recursive definitions of a filter condition using a (...) looping construct -- since this in itself depends on the filter condition.

Note that the GPPFILTER and TEXFILTER predefined macros which the above replaces are deprecated and should not be used.


Go to the first, previous, next, last section, table of contents.