home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / bfast.zip / DEMO.CPP < prev    next >
C/C++ Source or Header  |  1992-03-18  |  2KB  |  61 lines

  1. //--------------------------------------------------------
  2. //  this is a demo program to illustrate the use the
  3. //  bFAST library
  4. ///
  5. //  include DEMO.CPP and BFAST.LIB in the project file
  6. //
  7. //  In order to run both demo program you neeed to execute
  8. //  Btrieve.exe first.
  9. //
  10. //  Chaolin Chang
  11. //--------------------------------------------------------
  12. #include <stdio.h>
  13.  
  14. #include "btrieve.hpp"
  15. #include "order.def"   // include the field definition file
  16. #include "order.hpp"   // include the field symbol file
  17.  
  18. void main()
  19. {
  20.     //
  21.     // create a Btrieve ans open it at the same time
  22.     //
  23.     Btrieve f("", "ORDER.DAT", order, FLD_ORDER);
  24.     if (f.Err())
  25.     {
  26.         printf("error code: %d\n", f.Err());
  27.         return;
  28.     }
  29.     int count=0;
  30.     printf("Record Order Ref    Customer\n");
  31.     printf("------ ------------ --------\n");
  32.     //
  33.     // read the first record
  34.     //
  35.     f.GetFirst();
  36.     for (;;)
  37.     {
  38.         //
  39.         // use Eof(), if you like
  40.         //
  41.         if (f.Err())
  42.             break;
  43.         //
  44.         // it will cause error if you do this
  45.         // printf("%s %s", f.fStr(ORDER_REFERENCE), f.fStr(CUSTOMER));
  46.         // because fStr() uses a static char [] as the common buffer
  47.         // to store the returned value
  48.         //
  49.         printf("%.6d ", ++count);
  50.         printf("%s ", f.fStr(ORDER_REFERENCE));
  51.         printf("%s\n", f.fStr(CUSTOMER));
  52.         //
  53.         // read the next record
  54.         //
  55.         f.GetNext();
  56.     }
  57.     //
  58.     // as f is destoryed, file is closed automatically
  59. }
  60.  
  61.