home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / dbase_c.zip / DBUTIL.C < prev    next >
Text File  |  1989-03-20  |  2KB  |  49 lines

  1. /**********************************************************************
  2. *             DBASE II UTILITIES FOR AZTEC C                          *
  3. *_____________________________________________________________________*
  4. *    These routine are intended to provide the C language programmer  *
  5. * with a set of I/O utilities to manipulate DBase II DBF files.  This *
  6. * will eventually include sorting, editting and  the likes.           *
  7. *                                                                     *
  8. *    (C) Copyright 1983                 Richard Hoffbeck              *
  9. **********************************************************************/
  10.  
  11. #include  "libc.h"
  12. #include  "dbase.h"
  13.  
  14. main(){
  15.    DBASE_FILE  *db_header, *db_open() ;
  16.    char        infile[14], db_buffer[100], name[10] , var_buf[30] ;
  17.    int         i, record ;   
  18.  
  19.    /*----- get the input file name -----*/
  20.    printf("Enter the input file name: "); scanf("%s",infile);
  21.    if( (db_header=db_open(infile)) == -1 ){
  22.       printf("\nUnable to open the input file\n\n\n\n");
  23.       exit();
  24.       }
  25.  
  26.    /*----- display the information -----*/
  27.    printf("\n\t\tDBase II file: %s",infile);
  28.    printf("\n\t\tModified on  : %u %u %u",db_header->month,db_header->day,db_header->year);
  29.    printf("\n\t\tContains %u records of length %u\n\n",db_header->rec_num,db_header->rec_len);
  30.    for( i=0; i<db_header->var_num ; i++) 
  31.       printf("\n\t\t\t %10s :  %u",db_header->field_desc[i].name,db_header->field_desc[i].var_len);
  32.  
  33.    /*----- test the lookup function -----*/
  34.    while( 1 ) {
  35.       printf("\nEnter the variable name: ") ;  scanf("%s", name) ;
  36.       printf("\nEnter the record number: ") ;  scanf("%d", &record ); 
  37.       if( strncmp(name,"quit",4) == 0 )
  38.          exit();
  39.       db_seek(db_header,record,0) ;
  40.       db_read(db_header,db_buffer,1) ;
  41.       if( lookup(name,db_header,db_buffer,var_buf) == ERROR )
  42.          printf("\nVariable not found in the table");
  43.       else {
  44.          printf("\n %s is ",name) ;
  45.          printf("%s",var_buf) ;
  46.       }
  47.    }
  48.  }
  49.