Show/Hide Toolbars

XSharp

NoteThis command is defined in a header file and will be preprocessed by the X# preprocessor to a function call. If you disable the standard header (-nostddefs) files then this command will not be available. If you tell the compiler to use a different standard header file (-stddef ) then this command may also be not available

Purpose

Set or clear a filter condition for the current work area.

Syntax

SET FILTER TO [<lCondition>]

Arguments

TO <lCondition>The condition used to filter records.
 
SET FILTER TO without an argument clears the filter condition.

Description

When a filter is set, records that do not meet the filter condition are not logically visible.  The filter condition can be returned as a string using the DBFilter() function.

That is, database operations which act on logical records will not consider these records except to access them specifically by record number.  So, for example, you can GOTO a filtered record or process one using the RECORD <nRecord> scope.

 

Note: Once a filter is set, it is not activated until the record pointer is moved from its current position.  You can use GO TOP to activate it.

 

SET FILTER TO when specified with a condition is functionally equivalent to DbSetFilter() with the condition expressed as a code block and a string.  SET FILTER TO with no arguments is equivalent to DBClearFilter().  

 

Tip: If the RDD you are using supports optimization, use SET OPTIMIZE to control whether the RDD will optimize the filter search based on the available orders in the work area.

Notes

Visibility: As with SetDeleted() , a filter has no effect on INDEX and REINDEX.  To create a conditional index, use the FOR condition of the INDEX command.

Examples

This example filters EMPLOYEE.DBF to only those records where the age is greater than 50:

 

USE employee INDEX name NEW
SET FILTER TO Age > 50
LIST Lastname, Firstname, Age, Phone
SET FILTER TO

Assembly

XSharp.RT.DLL

See Also

DbClearFilter(), DbFilter(), DbSetFilter(), SET OPTIMIZE, SetDeleted()