home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a007 / 1.ddi / KEYADD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-15  |  1.5 KB  |  63 lines

  1. /* The SETUP.C program must be compiled and run before this example */
  2. /* can be executed. */
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "pxengine.h"
  8.  
  9. #define TABLENAME  "table"
  10.  
  11. char commandline[128];   /* string buffer used to build command line */
  12.  
  13. FIELDHANDLE hFldsPrimary[]      = { 1, 2 };
  14. FIELDHANDLE hFldsSecondary[]    = { 3 };
  15. FIELDHANDLE hFldsIncSecondary[] = { 6 };
  16.  
  17. #define NPRIMARYFLDS (sizeof(hFldsPrimary) / sizeof(FIELDHANDLE))
  18.  
  19. int main(void)
  20. {
  21.   PXCODE pxErr;
  22.  
  23.   /* Attempt to initialize the Engine for local use. */
  24.  
  25.   pxErr = PXInit();
  26.   if (pxErr != PXSUCCESS)
  27.   {
  28.     printf("%s\n", PXErrMsg(pxErr));
  29.     return pxErr;
  30.   }
  31.  
  32.   /* Create a primary index on fields 1 and 2. */
  33.  
  34.   if ((pxErr = PXKeyAdd(TABLENAME, NPRIMARYFLDS, hFldsPrimary, PRIMARY))
  35.     != PXSUCCESS)
  36.     printf("%s\n", PXErrMsg(pxErr));
  37.  
  38.   /* Create a secondary index on field 3. */
  39.  
  40.   if ((pxErr = PXKeyAdd(TABLENAME, 1, hFldsSecondary, SECONDARY)) 
  41.     != PXSUCCESS)
  42.     printf("%s\n", PXErrMsg(pxErr));
  43.  
  44.   /* Create a maintained secondary index on field 6. */
  45.  
  46.   if ((pxErr = PXKeyAdd(TABLENAME, 1, hFldsIncSecondary, INCSECONDARY))
  47.     != PXSUCCESS)
  48.     printf("%s\n", PXErrMsg(pxErr));
  49.  
  50.   /* Build the string needed to list our index files. */
  51.  
  52.   strcpy(commandline,"dir ");
  53.   strcat(commandline,TABLENAME);
  54.   strcat(commandline,".*");
  55.  
  56.   /* Spawn a DOS command interpreter to process the DIR command. */
  57.  
  58.   system(commandline);
  59.  
  60.   PXExit();
  61.   return(pxErr);
  62. }
  63.