SearchFolder method

The active folder is searched with the current field values. These values were set by default, by the user, or by the SetFolderSearchFieldData method.

Method:
short SearchFolder(
boolean Append )
Parameters
Append
If nonzero, indicates that the results of the search are to be appended to the existing document list; otherwise, that the results of the search are to replace the existing document list.
Description

The search operation can be cancelled by using the CancelOperation method. If a cancel facility is made available to the user, it is desirable to call the SearchFolder method on a background thread and allow the user interface thread to monitor the cancellation signal.

Return Value
Refer to return codes.
See Also
OpenFolder, GetNumFolderSearchFields, GetFolderSearchFieldNames, SetFolderSearchFieldData, CancelOperation, WasOperationCancelled, and ShowWaitCursorDuringCancelableOperation methods

C/C + +

The following example retrieves the names of the active folder search fields, gives a user the opportunity to set the values for these fields, and initiates a search of the folder.
 CArsOle * pArsCtrl;
 ArsOleName * pNames;
 CListBox * pFieldList, * pOprList;
 CEdit * pValue1, * pValue2;
 char name[ sizeof( ArsOleName ) ];
 char value1[ sizeof( ArsOleValue ) ];
 char value2[ sizeof( ArsOleValue ) ];
 short rc, j, opr, num_fields;
 VARIANT vari;
   .
   .
 struct _OprMap
 {
   short  code;
   char * pText;
 } OprMap

 static OprMap Oprs[] =
   { { ARS_OLE_OPR_EQUAL,                  "Equal" },
     { ARS_OLE_OPR_NOT_EQUAL,              "Not Equal" },
          .
          .
     { ARS_OLE_OPR_LIKE,                   "Like" },
     { ARS_OLE_OPR_NOT_LIKE,               "Not Like" } };

 #define NUM_OPRS  ( sizeof(Oprs) / sizeof(OprMap) )
   .
   .
 // During dialog initialization:

 rc = pArsCtrl->GetNumFolderSearchFields( &vari );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;
 num_fields = var.iVal;

 pNames = new ArsOleName[ max( num_fields, 1 ) ];
 rc = pArsCtrl->GetFolderSearchFieldNames( (IUnknown*)pNames, num_fields );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;

 for ( j = 0; j < num_fields; j++ )
   pFieldList->InsertString( -1, pNames[j] );
 pFieldList->SetCurSel( 0 );

 for ( j = 0; j < NUM_OPRS; j++ )
 {
   pOprList->InsertString( -1, Oprs[j].pText );
   pOprList->SetItemData( j, (DWORD)Oprs[j].code );
 }
 pOprList->SetCurSel( 0 );
   .
   .
 // During SET FIELD button processing:

 pFieldList->GetText( pFieldList->GetCurSel( ), name );
 opr = (short)pOprList->GetItemData( pOprList->GetCurSel( ) );
 pValue1->GetWindowText( value1, sizeof(value1) );
 pValue2->GetWindowText( value2, sizeof(value2) );

 rc = pArsCtrl->SetFolderSearchFieldData( name, opr, value1, value2 );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;
   .
   .
 // During OK button processing:

 rc = pArsCtrl->SearchFolder( FALSE );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;
   .
   .

Visual Basic

Dim rc, count, i, j As Integer
Dim num_fields, num_docs As Variant
Dim Names() As String
Dim Line As String
Dim Temp As String
Dim Oprs As Variant

 .
 .

Oprs = Array ("Equal", "Not Equal", ..., "Like", "Not Like")

rc = ArsOle.GetNumFolderSearchFields(num_fields)
If rc <> ARS_OLE_RC_SUCCESS Then
    MsgBox "ERROR"
    End
End If

ReDim Names(num_fields -1)

For count = 0 To num_fields -1
    rc = ArsOle.GetFolderSearchFieldName(count, Temp)
    Names(count) = Temp
Next count

for count = 0 To num_fields -1
    lbFieldList.AddItem Names(count)
Next count

for count = 0 To UBound(Oprs) -1
    lbOprList.AddItem (Oprs(count))
Next count
' During SET FIELD button processing
rc = ArsOle.SetFolderSearchFieldData (lbFieldList.List(lbFieldList.ListIndex),
                                      lbOprList.ListIndex,
                                      txtValue1.Value,
                                      txtValue2.Value)
If rc <> ARS_OLE_RC_SUCCESS Then
    MsgBox "ERROR"
    End
End If
 .
 .
 .
'During OK button processing:

rc = ArsOle.SearchFolder (False)
If rc <> ARS_OLE_RC_SUCCESS Then
    MsgBox "ERROR"
    End
End If