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 scdnkmake(
           int datahandle,
           int indexhandle,
           void **key );

PROTOTYPE IN
   sc_base.h

DESCRIPTION
   scdnkmake will build an index key using the key expression of the index
   file specified by indexhandle and the data found in the output buffer
   of the data file datahandle. Memory space for the key will be
   allocated and the address of this block will be returned.

   The key expression can consist of either the data field name or one of
   five dBASE functions or a combination thereof. Data field types of date,
   numeric, or character are allowed. dBASE functions dtoc, left,
   right, str, and substr are currently supported by scdnkmake.

   Following is a brief description of the five expression functions:

   dtoc will convert data from a date field to an ASCIIZ string of the
   format "mm/dd/yy". Syntax is:

         dtoc(field_name)

   left will return the left portion of a character field as an ASCIIZ
   string. The number of characters returned is specified after the field
   name. Syntax is:

         left(field_name,number)

   right will return the right portion of a character field as an ASCIIZ
   string. The number of characters returned is specified after the field
   name. This is a count from the right side of the field. Syntax is:

         right(field_name,number)

   str will convert a numeric field to an ASCIIZ string. The total length
   of the string and the number of decimal places are optional parameters.
   The default string length is 10 and the number of decimal places is 0.
   Syntax is:

         str(field_name,length,decimal_places)

   substr will return the middle portion of a character field. The
   starting offset into the field is a required parameter. The number of
   characters to be used is an optional parameter whose default value is the
   remainder of the field. Syntax is:

         substr(field_name,start,count)

   An example of a more complex key expression:

         right(dtoc(date),2)+left(dtoc(date,2)

   This expression would cause scdnkmake to create an index key string
   consisting of the year and month ("yymm"). For example if date equals
   "2/13/89" the resultant key would be "8902".

NOTES
   For key expressions consisting of only one data field scdnkmake is
   probably an overkill. You can easily generate these keys yourself. See
   scdnkdate for information on date string to key translation.
   scdnkmake is a fairly large module and if not needed probably should
   not be used. This function is best used when the key expression is more
   complex.

   Memory is allocated for the generated key and it is the responsibility of
   the caller to free this memory when finished.

EXAMPLE
   #include <sc_base.h>

   void main()
   {
     int ndx, dbf;
     char *key;
     long recno;

     scdinit(20,0);
     if (scddopenx(&dbf,"TOC.DBF",0) == SC_SUCCESS) {
       if (scdnopenx(&ndx, "TOCNAME.NDX", SC_BUFFER) == SC_SUCCESS) {
         scddfput(dbf,0,"HELLO.C");
         scddrput(dbf,&recno,SC_ADD);
         scdnkmake(dbf,ndx,(void **) &key);
         scdnkadd(ndx,key,recno);
         free(key);         /* free memory allocated for key */
         scdnclose(ndx);
       }
       scddclose(dbf);
     }
     scdterm();
   }

See Also: scdncreate scdnkdate

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