sx_SetFilter

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_SetFilter

VB Declaration

Declare Sub sx_SetFilter Lib "Apollo9.dll"

(ByVal cpExpression As Any)

C Declaration

VOID FAR PASCAL sx_SetFilter

(BYTEP cpExpression)

Description

Defines a subset of the current table according to the condition passed as a filter. sx_SetFilter as a function exists for compatibility purposes.

Note: It is recommended that the sx_Query function be used instead of sx_SetFilter, since sx_SetFilter does not attempt to perform any query optimization whatsoever, as the sx_Query function does.

Parameters

cpExpression: An xBase expression that will evaluate to a logical True or False.

Note: To remove a filter pass this parameter as a NULL string (0&).

Logical Operator Precedence

Logical operator precedence is .NOT., .AND., and finally .OR. sx_Query expressions with more than two elements using different logical operators to join the elements must be carefully constructed by observing the precedence rules.

 

See sx_Query for a complete discussion on the rules of filter expression construction.

VB Example

If Dir$("c:\vb\test\cust.dbf") = "" Then

MsgBox "Master file missing"

End

End If

 

CustArea = sx_Use( "\vb\test\cust.dbf", "cust", READWRITE, SDEFOX )

 

' display customers in China only that have a last name

sx_SetFilter "upper(trim(place))='CHINA' .and. left(last, 1)>' '"

C Example

sx_Use("c:\\vb\\cust.dbf", "cust", READWRITE, SDENTX);

 

// display customers in China only that have a last name

sx_SetFilter("upper(place)='CHINA' .and. left(last, 1)>' '");

sx_GoTop;

See Also

sx_DBFilter, sx_SetDeleted, sx_Query