Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- SoftC Database Library v2.1 Guide - usage http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
USAGE
   int scdnkfind(
           int handle,
           void *key,
           long *recno,
           int method );

PROTOTYPE IN
   sc_base.h

DESCRIPTION
   scdnkfind supports two key search methods (determined by method):
   SC_EXACT - find an exact match with key and recno, and
   SC_FIRST - finds the first logical occurrence of key in the index
   and returns the associated record number recno if found.

   If a match cannot be found, the current key will be the physical key which
   would immediately precede key. The current key's value and data record
   number will be returned in key and recno.

NOTES
   The user must ensure that the buffer used to return the key is large
   enough to hold the entire key. The maximum length of the key can be
   determined via a call to scdninfo.

   When searching using character keys it is not necessary to pad the key
   string to size with spaces (" "), the function will automatically do this
   for you.

   Searching for partial keys can be accomplished by using the SC_FIRST
   method. For example, you are using a fifteen character key size and you
   want to find the first entry where the first five characters are "ABCDE".
   All you need do is copy that five character ASCIIZ string into your key
   buffer and then call scdnkfind. The function will space pad to length
   and then find the first matching entry.

   Numeric keys are returned as doubles, and character keys are returned as
   strings.

EXAMPLE
   #include <string.h>
   #include <softc.h>
   #include <sc_base.h>

   void main()
   {
     int ndx;
     char key[16];
     long recno;

     scdinit(20,0);
     if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) == SC_SUCCESS) {
       strcpy(key,"ABCDE");
       recno = 7L;
       if (scdnkfind(ndx,key,&recno,SC_FIRST) != SC_SUCCESS
         puts(scemsg());
       scddclose(ndx);
     }
     scdterm();
   }

See Also: scdninfo

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson