GetNumFolderSearchFields method

The number of search fields for the active folder is returned in the specified variable.

Method:
short GetNumFolderSearchFields(
VARIANT * pNumFields )
Parameters
pNumFields
Points to a variable to receive the number of search fields for the active folder. On return, this variable is set to type VT_I2.
Description
This value can be used with the GetFolderSearchFieldNames method to prepare for setting the search field values for a folder.
Return Value
Refer to return codes.
See Also
GetFolderSearchFieldNames, SetFolderSearchFieldData, and SearchFolder

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)
    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