| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Returns the filter expression of a work area-
DbFilter() --> cFilter
The function returns a character string containing the filter expression of a work area, or a null string ("") when no filter is set.
The DbFilter() function can be used to query the filter condition set in a work area as a character string. This allows for temporarily disabling a filter and restore it later using the macro operator (&). Note, however, that this works only if a filter condition does not refer to lexical variables (GLOBAL, LOCAL, STATIC).
By default, DbFilter() operates in the current work area. Use an aliased expression to query filter expressions of different work areas.
| See also: | DbClearFilter(), DbRelation(), DbRSelect(), DbSetFilter(), SET FILTER |
| Category: | Database functions |
| Source: | rdd\dbcmd.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example outlines a programming technique for saving
// and restoring a filter condition in a work area
PROCEDURE Main
LOCAL cFilter
USE Customer ALIAS CUst SHARED
INDEX ON Upper(Lastname+Firstname) TO Cust01
SET FILTER TO Cust->Lastname = "S"
GO TOP
? Cust->Lastname // result: Shiller
? cFilter := DbFilter() // result: Cust->Lastname = "S"
DbClearFilter()
GO TOP
? Cust->Lastname // result: Alberts
SET FILTER TO &cFilter
GO TOP
? Cust->Lastname // result: Shiller
CLOSE Cust
RETURN
http://www.xHarbour.com