ProjectDet::SetFilter (Interface: ProjectDet)
 
Sets a filter on the file.
 
VARIANT_BOOL SetFilter (
    BSTR bsExpression
)
 
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.
 
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, Exact C-Logic has choosen not to implement a GetFirst- nor a GetLast-method, since they can easily be simulated with 'while (GetPrevious ())' and 'while (GetNext ())'.
 
See Also
CreateProjectDet
SeekBySysNum
GetNext
 
Samples
 
C++
 
// Establish a sort order
pProjectDet->SeekBySysNum (smFirst, 0);

// Apply a filter, limiting to all project details that have to be invoiced
if (pProjectDet->SetFilter ("@PJD.ToInvoice == 1"))
{    
    // Navigate through the filtered file
    do
    {
        // Process record data
    }
    while (pProjectDet->GetNext ());
}

// Cancel the filter
pProjectDet->SetFilter ("");

C#
 
// Establish a sort order
oProjectDet.SeekBySysNum (eSeekMode.smFirst, 0);

// Apply a filter, limiting to all project details that have to be invoiced
if (oProjectDet.SetFilter ("@PJD.ToInvoice == 1"))
{    
    // Navigate through the filtered file
    do
    {
        // Process record data
    }
    while (oProjectDet.GetNext ());
}

// Cancel the filter
oProjectDet.SetFilter ("");

VBS
 
' Establish a sort order
Call oProjectDet.SeekBySysNum(smFirst, 0)

' Apply a filter, limiting to all project details that have to be invoiced
If oProjectDet.SetFilter("@PJD.ToInvoice == 1") = True Then
    ' Navigate through the filtered file
    Do
        ' Process record data
    Loop While oProjectDet.GetNext() = True
End If

' Cancel the filter
Call oProjectDet.SetFilter("")

VB.NET
 
' Establish a sort order
oProjectDet.SeekBySysNum(eSeekMode.smFirst, 0)

' Apply a filter, limiting to all project details that have to be invoiced
If oProjectDet.SetFilter("@PJD.ToInvoice == 1") = True Then
    ' Navigate through the filtered file
    Do
        ' Process record data
    Loop While oProjectDet.GetNext() = True
End If

' Cancel the filter
oProjectDet.SetFilter("")