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

PROTOTYPE IN
   sc_base.h

DESCRIPTION
   scdckmake will build an index key using the key expression of the
   index file specified by indexhandle and the data found in the record
   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 Clipper functions or a combination thereof. Data field types of date,
   numeric, or character are allowed. Clipper functions dtoc, left,
   right, str, and substr are currently supported by scdckmake.

   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 scdckmake 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 scdckmake is
   probably an overkill. You can easily generate these keys yourself.
   scdckmake 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 <stdio.h>
   #include <softc.h>
   #include <sc_base.h>

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

     scdinit(20,0);
     if (scddopenx(&dbf, "TOC.DBF", 0) == SC_SUCCESS) {
       if (scdcopenx(&ntx, "TOCNAME.NTX", SC_BUFFER) == SC_SUCCESS) {
         scddfput(dbf,0,"ABCDEF.XYZ");
         scddrput(dbf,&recno,SC_ADD);
         scdckmake(dbf,ntx,(void **) &key);
         printf("%s\n",key);
         scdckadd(ntx,key,recno);
         free(key);         /* free memory allocated for key */
         scdcclose(ntx);
       }
       scddclose(dbf);
     }
     scdterm();
   }

See Also: scdccreate

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