|
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
pCntry->SeekBySysNum (smFirst, 0);
// Apply a filter, limiting to all country cards with 'EUR' as ISO currency code
if (pCntry->SetFilter ("@CNT.IsoCurrencyCode == \"EUR\"", VARIANT_FALSE))
{
// Navigate through the filtered file
do
{
// Process record data
}
while (pCntry->GetNext ());
}
// Cancel the filter
pCntry->SetFilter ("", VARIANT_FALSE);
|
|
|
C# |
|
// Establish a sort order
oCntry.SeekBySysNum (eSeekMode.smFirst, 0);
// Apply a filter, limiting to all country cards with 'EUR' as ISO currency code
if (oCntry.SetFilter ("@CNT.IsoCurrencyCode == \"EUR\"", false))
{
// Navigate through the filtered file
do
{
// Process record data
}
while (oCntry.GetNext ());
}
// Cancel the filter
oCntry.SetFilter ("", false);
|
|
|
VBS |
|
' Establish a sort order
Call oCntry.SeekBySysNum(smFirst, 0)
' Apply a filter, limiting to all country cards with 'EUR' as ISO currency code
If oCntry.SetFilter("@CNT.IsoCurrencyCode == ""EUR""", False) = True Then
' Navigate through the filtered file
Do
' Process record data
Loop While oCntry.GetNext() = True
End If
' Cancel the filter
Call oCntry.SetFilter("", False)
|
|
|
VB.NET |
|
' Establish a sort order
oCntry.SeekBySysNum(eSeekMode.smFirst, 0)
' Apply a filter, limiting to all country cards with 'EUR' as ISO currency code
If oCntry.SetFilter("@CNT.IsoCurrencyCode == ""EUR""", False) = True Then
' Navigate through the filtered file
Do
' Process record data
Loop While oCntry.GetNext() = True
End If
' Cancel the filter
oCntry.SetFilter("", False)
|
|