home *** CD-ROM | disk | FTP | other *** search
-
- /* t4index.c
-
- (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
-
- 1. Checks to make sure dBASE Function 'RECNO()' is working while indexing.
- */
-
- #include "p4misc.h"
- #include "d4all.h"
- #include "w4.h"
- #include "u4error.h"
-
- #include <string.h>
- #include <stdlib.h>
-
- static FIELD fields[]=
- {
- { "C", 'C', 10, 0, 0 },
- } ;
-
-
- main( int argc, char **argv )
- {
- int r, i_ref, c ;
- long n, i_rec ;
-
- #ifdef NO_HUGE
- #ifdef IS_386
- d4init() ;
- #else
- d4initialize( 4, 4, 20, 1000, 20000L ) ;
- #endif
- #else
- d4init() ;
- #endif
- w4clear(-1) ;
-
- r = 0 ;
-
- if ( argc < 2 )
- {
- w4( r++,0, "Index Test" ) ;
- w4( r++,0, "t4index num_records" ) ;
- w4exit(0) ;
- }
-
- n = atol( argv[1] ) ;
- r++ ;
- w4( ++r,0, "Number of Records:" ) ;
- w4long( r,w4col(), n, 6) ;
- r++ ;
-
- d4create( "t4index", 1, fields, 0 ) ;
-
- w4( w4row()+1,0, "Writing Rec:" ) ;
- c = w4col() ;
-
- for ( i_rec = 1L; i_rec <= n; i_rec++ )
- {
- w4long( w4row(),c, i_rec, 6 ) ;
-
- if ( d4write(0L) < 0 )
- {
- u4error( 0, "t4index: d4write", (char *) 0 ) ;
- w4exit(1) ;
- }
- }
-
- w4( w4row()+1,0, "Checking Indexing of Blank Field" ) ;
- i_ref = i4index( "t4index", "C", 0, 0 ) ;
- if ( i4check( i_ref ) != 0 )
- {
- u4error( 0, "t4index: i4check", (char *) 0 ) ;
- w4exit(1) ;
- }
-
- w4( w4row()+1,0, "Checking Indexing by RECNO()" ) ;
- i_ref = i4index( "t4index", "RECNO()", 0, 0 ) ;
- if ( i4check( i_ref ) != 0 )
- {
- u4error( 0, "t4index: i4check 2", (char *) 0 ) ;
- w4exit(1) ;
- }
-
- d4close_all() ;
-
-
- #ifdef H4TEST
- {
- int rc ;
- d4init_undo() ;
- rc = h4free_check(32000) ;
- d4init() ;
- if ( rc != 0 )
- {
- u4error( 0, "t4index: Memory items not freed", (char *) 0 );
- w4exit(1) ;
- }
- }
- #endif
-
- w4handle(1) ;
- w4( w4row()+1,0, "t4index: SUCCESS" ) ;
- w4exit(0) ;
- }
-
-