home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / DISPST.ZIP / DISPSTRU.C next >
Text File  |  1991-11-22  |  3KB  |  101 lines

  1. /*--------------------------------------------------------------------------*
  2.  *   Copyright (c) AlphaWare, 1991                                          *
  3.  *   Released to Public Domain, 1991                                        *
  4.  *                                                                          *
  5.  *   AlphaWare                                                              *
  6.  *   2010 Appalachia                                                        *
  7.  *   Mequite, Texas 75149                                                   *
  8.  *   (214) 289-2696                                                         *
  9.  *                                                                          *
  10.  *   DISPSTRU.EXE <datebase_filename> [/FF] [> lpt1/lpt2/prn/filename]      *
  11.  *                                                                          *
  12.  *     <database_filename> : This can be a filename or a wildcard           *
  13.  *                           LOG.DBF, LO?.DBF, *.DBF, AA??A?.DBF            *
  14.  *                           filename must end with '.DBF'                  *
  15.  *                                                                          *
  16.  *     /FF                 : This is optional, it places a Form Feed char   *
  17.  *                           at the end of each database file               *
  18.  *                                                                          *
  19.  *     > lpt1/prn/filename : This is optional, it places the output to a    *
  20.  *                           filename or the printer                        *
  21.  ****************************************************************************/
  22.  
  23.  
  24.  
  25.  
  26. #include <d4base.h>
  27. #include <stdio.h>
  28. #include <dos.h>
  29. #include <string.h>
  30.  
  31.  
  32. static char temp_buffer[130];
  33.  
  34. int  rc;
  35. struct find_t next_file_ptr;
  36.  
  37. int main( int argn, char *argc[] )
  38. {
  39.    int j;
  40.    long ref;
  41.  
  42.     printf("DISPSTRU.EXE    ---  Display dBASE file structures        Version 1.00\n");
  43.     printf("                     Copyright (c) 1991, AlphaWare\n");
  44.     printf("                     Released to the Public Domain 1991\n\n");
  45.     
  46.  
  47.     if ( argn < 2)
  48.     {
  49.         printf("Usage is: DISPSTRU <database_name> [/FF] [> lpt1/prn/filename]\n");
  50.         exit(0);
  51.     }
  52.  
  53.     if (((rc = strlen(argc[1])) < 5) || (strcmpi( &argc[1][(rc - 4)] , ".DBF") != 0))
  54.  
  55.     {
  56.         printf("*ERROR*: Database Filename must end with \".DBF\"\a\n");
  57.         exit(2);
  58.     }
  59.  
  60.  
  61.     for ( rc = _dos_findfirst( argc[1], _A_NORMAL, &next_file_ptr );
  62.           rc == 0;
  63.           rc = _dos_findnext( &next_file_ptr ) )
  64.     {
  65.  
  66.     if ( d4use( next_file_ptr.name ) < 0) exit(1);
  67.  
  68.     printf("                                       Database Structure for : %s\n", next_file_ptr.name);
  69.     printf("        Fields     Type   Length  Dec       Number of Records : %ld\n",
  70.             d4reccount() );
  71.     printf("       ----------  ----   ------  ----\n");
  72.  
  73.    for ( j=1; j <= f4num_fields(); j++ )
  74.    {
  75.      ref = f4j_ref( j );
  76.  
  77.       printf(" %3d   %-10s    %c      %4d  %4d\n",
  78.              j, f4name(ref), f4type(ref), f4width(ref), f4decimals(ref));
  79.       
  80.  
  81.    }
  82.       if (strcmpi(argc[2], "/FF") == 0) 
  83.          printf("\f");
  84.       else
  85.          printf("\n\n\n\n");
  86.  
  87.  
  88.     }
  89.  
  90.     exit(0);
  91.  
  92. }
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.