|
Sets a filter on the file. |
|
|
VARIANT_BOOL SetFilter ( BSTR bsExpression, VARIANT_BOOL bWait ) |
|
|
Parameters | bsExpression | [in] The expression, which is compatible with filters in the Venice modules but limited to the file itself and the system file, you want to use as a filter. | bWait | [in] If this parameter is False, a call to this method returns after the first record is found.
The remaining records are searched in the background and this continues while other code is executed.
Until this process has finished searching for records, it is not recommended to use objects of another dossier or financial year.
If it is necessary to use objects of another dossier or financial year while applying a filter, set this parameter to True and this method will wait until the background process has completed. At that moment, it is safe to use other objects.
| | Return value |
True if a at least one record is found after applying the filter, otherwise False. | | Remarks |
| Using the SetFilter method to get a list of records is (almost) always slower than using a specific SeekBy/GetNext loop. This is particularly true and can make a significant difference if you can limit the records instead of filtering them. |
| The sort order of the filtered file is determined by the preceding SeekBy-method. |
| Filtering a file always starts with the first record according to the sort order and is not influenced by the current position in the file. Unless prematurely canceled, using SetFilter will fetch every record according to that key. |
| After applying a filter, at least one record is sought and the file is positioned on the first record that matches the filter. For a large file this can take a while. Navigating through the filtered file is done with GetNext and GetPrevious. |
| Although a SeekBy-method modifies the current position and sort order in a standard file and also has an effect on subsequent calls to GetNext and GetPrevious, this is not the case for a filtered file. A filter has no effect on the result of a SeekBy-method, and a SeekBy-method does not modify the sort order or position in a filtered file. |
| To cancel a filter, call this method with an empty expression. |
| To keep the interface as simple as possible, there is neither a GetFirst- nor a GetLast-method, since they can easily be simulated with 'while (GetPrevious ())' and 'while (GetNext ())'. |
|
|
See Also |
|
|
|
Samples |
|
|
C++ |
|
// Establish a sort order
pBook->SeekBySysNum (smFirst, 0);
// Apply a filter, limiting to all active books
if (pBook->SetFilter ("@BOO.Active == 1", VARIANT_FALSE))
{
// Navigate through the filtered file
do
{
// Process record data
}
while (pBook->GetNext ());
}
// Cancel the filter
pBook->SetFilter ("", VARIANT_FALSE);
|
|
|
C# |
|
// Establish a sort order
oBook.SeekBySysNum (eSeekMode.smFirst, 0);
// Apply a filter, limiting to all active books
if (oBook.SetFilter ("@BOO.Active == 1", false))
{
// Navigate through the filtered file
do
{
// Process record data
}
while (oBook.GetNext ());
}
// Cancel the filter
oBook.SetFilter ("", false);
|
|
|
VBS |
|
' Establish a sort order
Call oBook.SeekBySysNum(smFirst, 0)
' Apply a filter, limiting to all active books
If oBook.SetFilter("@BOO.Active == 1", False) = True Then
' Navigate through the filtered file
Do
' Process record data
Loop While oBook.GetNext() = True
End If
' Cancel the filter
Call oBook.SetFilter("", False)
|
|
|
VB.NET |
|
' Establish a sort order
oBook.SeekBySysNum(eSeekMode.smFirst, 0)
' Apply a filter, limiting to all active books
If oBook.SetFilter("@BOO.Active == 1", False) = True Then
' Navigate through the filtered file
Do
' Process record data
Loop While oBook.GetNext() = True
End If
' Cancel the filter
oBook.SetFilter("", False)
|
|