home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / TEST / T4INDEX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  2.0 KB  |  108 lines

  1.  
  2. /* t4index.c
  3.  
  4.    (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
  5.  
  6.    1.  Checks to make sure dBASE Function 'RECNO()' is working while indexing.
  7. */
  8.  
  9. #include  "p4misc.h"
  10. #include  "d4all.h"
  11. #include  "w4.h"
  12. #include  "u4error.h"
  13.  
  14. #include <string.h>
  15. #include <stdlib.h>
  16.  
  17. static FIELD  fields[]=
  18. {
  19.    { "C", 'C', 10, 0, 0 },
  20. } ;
  21.  
  22.  
  23. main( int argc, char **argv )
  24. {
  25.    int  r, i_ref, c ;
  26.    long n, i_rec ;
  27.  
  28.    #ifdef NO_HUGE
  29.       #ifdef IS_386
  30.          d4init() ;
  31.       #else
  32.          d4initialize( 4, 4, 20, 1000, 20000L ) ;
  33.       #endif
  34.    #else
  35.       d4init() ;
  36.    #endif
  37.    w4clear(-1) ;
  38.  
  39.    r = 0 ;
  40.  
  41.    if ( argc < 2 )
  42.    {
  43.       w4( r++,0, "Index Test" ) ;
  44.       w4( r++,0, "t4index  num_records" ) ;
  45.       w4exit(0) ;
  46.    }
  47.  
  48.    n =  atol( argv[1] ) ;
  49.    r++ ;
  50.    w4(   ++r,0, "Number of Records:" ) ;
  51.    w4long( r,w4col(), n, 6)  ;
  52.    r++ ;
  53.  
  54.    d4create( "t4index", 1, fields, 0 ) ;
  55.  
  56.    w4( w4row()+1,0, "Writing Rec:" ) ;
  57.    c =  w4col() ;
  58.  
  59.    for ( i_rec = 1L; i_rec <= n; i_rec++ )
  60.    {
  61.       w4long( w4row(),c, i_rec, 6 ) ;
  62.  
  63.       if ( d4write(0L) < 0 )
  64.       {
  65.      u4error( 0, "t4index:  d4write", (char *) 0 ) ;
  66.          w4exit(1) ;
  67.       }
  68.    }
  69.  
  70.    w4( w4row()+1,0, "Checking Indexing of Blank Field" ) ;
  71.    i_ref =  i4index( "t4index", "C", 0, 0 ) ;
  72.    if ( i4check( i_ref )  != 0 )
  73.    {
  74.       u4error( 0, "t4index:  i4check", (char *) 0 ) ;
  75.       w4exit(1) ;
  76.    }
  77.  
  78.    w4( w4row()+1,0, "Checking Indexing by RECNO()" ) ;
  79.    i_ref =  i4index( "t4index", "RECNO()", 0, 0 ) ;
  80.    if ( i4check( i_ref )  != 0 )
  81.    {
  82.       u4error( 0, "t4index:  i4check 2", (char *) 0 ) ;
  83.       w4exit(1) ;
  84.    }
  85.  
  86.    d4close_all() ;
  87.  
  88.  
  89.    #ifdef H4TEST
  90.    {
  91.       int  rc ;
  92.       d4init_undo() ;
  93.       rc = h4free_check(32000) ;
  94.       d4init() ;
  95.       if ( rc != 0 )
  96.       {
  97.          u4error( 0, "t4index:  Memory items not freed", (char *) 0 );
  98.          w4exit(1) ;
  99.       }
  100.    }
  101.    #endif
  102.  
  103.    w4handle(1) ;
  104.    w4( w4row()+1,0, "t4index:  SUCCESS" ) ;
  105.    w4exit(0) ;
  106. }
  107.  
  108.