home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / cwt2.zip / DBREAD.C < prev    next >
Text File  |  1989-11-25  |  1KB  |  34 lines

  1. #include <stdio.h>
  2. #include <c_wndw.h>
  3. #include <c_ndx.h>
  4. /*
  5. *    Copyright 1989, Marietta Systems, Inc.
  6. *    All rights reserved
  7. */
  8.  
  9. /*
  10. *    This program opens a dBASE file and its associated index file and
  11. *   reads sequentially through it displaying the contents of the field
  12. *    LASTNAME from each record.
  13. */
  14.  
  15. void main ()
  16. {
  17.      int fh, ndx, ret, x;
  18. /* Initialize and setup */
  19.      clr_scrn ("Indexed read");
  20.      fh = fileopen ("MARIETTA\\FRIENDS.DBF", dbase3, readonly);
  21.      if (fh <= 0) goodbye (10); /* file open error */
  22.      ndx = ndxopen (fh, "MARIETTA\\FRIENDS.NDX");
  23.      if (ndx <= 0) goodbye (11);
  24. /* read file sequentially through index */
  25.      for (ret = ndxread (ndx, firstrec), x = 1 ; ret > 0 ;
  26.                ret = ndxread (ndx, nextrec), x++ )
  27.           dispdbf (fh, dbffield (fh, "LASTNAME"), x, 1, high);
  28. /* end of program */
  29.      fileclos (fh); /* also automatically closes the index file */
  30.      display ("Press any key to terminate", x, 40, blink);
  31.      read_kb ();
  32.      goodbye (0);
  33. }
  34.