home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / codebase.zip / D4LIST.C < prev    next >
Text File  |  1993-01-11  |  2KB  |  58 lines

  1. /*********************************************************************
  2.  
  3. d4list.c     (c)Copyright Sequiter Software Inc., 1990-1991.
  4. All rights reserved.
  5.  
  6. Description:
  7. ============
  8.  
  9.     This example program, as discussed in the CodeBase manual on page 4,
  10.     simply opens an existing database file with it's index file, goes to 
  11.     the top of the file and lists the records to the screen as it skips
  12.     to the end of the file.
  13.  
  14. NOTE: Make sure that the accompanying database files, 'DATABASE.DBF' 
  15. and 'DATABASE.MDX' are with this file when executing the program.
  16.  
  17. *********************************************************************/
  18.  
  19. #include "d4all.h"
  20.  
  21. #ifdef __TURBOC__
  22.    extern unsigned  _stklen =  10000 ;  /* Borland only */
  23. #endif
  24.  
  25. void main()
  26. {
  27.  
  28.    CODE4   code_base ;
  29.    DATA4  *base ;
  30.    FIELD4 *field_ptr ;
  31.    int      j ;
  32.    
  33.    d4init( &code_base ) ;
  34.    
  35.    /* Open the data file.  If there is a production MDX and/or MEMO file 
  36.       file, they are also automatically opened. */
  37.    
  38.    base =  d4open( &code_base, "DATAFILE" ) ;
  39.    e4exit_test( &code_base ) ;
  40.    
  41.    /* Loop through the entire data file. */
  42.    for ( d4top(base); ! d4eof(base); d4skip(base,1) )
  43.    {
  44.       printf( "\n" ) ;  /* Display the record on a new line. */
  45.       
  46.        /* Loop through every field */
  47.       for ( j = 1; j <= d4num_fields(base); j++ )
  48.       {
  49.          field_ptr =  d4field_j( base, j ) ;
  50.          printf( "  %s", f4memo_str( field_ptr ) ) ; /* Display the field. */
  51.       }
  52.    }
  53.    d4close_all(&code_base) ;
  54.    
  55.    e4exit(&code_base) ;
  56. }
  57.  
  58.