Function : Search

NSFSearch - Scans database or directory, processing matching items.
----------------------------------------------------------------------------------------------------------

#include <nsfsearc.h>

STATUS LNPUBLIC NSFSearch(
DBHANDLE hDB,
FORMULAHANDLE hFormula,
char far *ViewTitle,
WORD SearchFlags,
WORD NoteClassMask,
TIMEDATE far *Since,
NSFSEARCHPROC EnumRoutine,
void far *EnumRoutineParameter,
TIMEDATE far *retUntil
);

Description :

This function scans all the notes in a database or files in a directory. Based on several search criteria, the function calls a user-supplied routine (an action routine) for every note or file that matches the criteria. NSFSearch is a powerful function that provides the general search mechanism for tasks that process all or some of the documents in a database or all or some of the databases in a directory.

Specify a formula argument to improve efficiency when processing a subset of the notes in a database.

Parameters :

Sample Usage :


if (error = IDCreateTable( sizeof(NOTEID), &hNoteIDTable ))
{
   printf( "Error: unable to create ID table.\n" );
   NSFDbClose( hDB );
   return( ERR(error) );
}

if (error = NSFSearch(
   hDB,            /* database handle */
   NULLHANDLE,     /* selection formula (select all notes) */
   NULL,           /* title of view in selection formula */
   0,              /* search flags */
   NOTE_CLASS_DOCUMENT,/* note class to find */
   NULL,           /* starting date (unused) */
   AddIDUnique,    /* call for each note found */
   &hNoteIDTable,  /* argument to AddIDUnique */
   NULL ))         /* returned ending date (unused) */

{
   printf( "Error: unable to search database.\n" );
   IDDestroyTable( hNoteIDTable );
   NSFDbClose( hDB );
   return (ERR(error));
}

/*  Loop over note IDs in the table. Call ProcessOneNote on each. */
if (error = IDEnumerate( hNoteIDTable,
                        ProcessOneNote, /* called for each ID */
                        &hDB ))         /* arg passed to func */
{
   printf( "Error: unable to enumerate documents in ID table.\n" );
}

IDDestroyTable( hNoteIDTable );


See Also :

NSFFormulaCompile
----------------------------------------------------------------------------------------------------------