home *** CD-ROM | disk | FTP | other *** search
- /* t4write.c
-
- (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
-
- Tests Code Base 'd4seek' and 'd4write' routines.
- */
-
- #include "p4misc.h"
- #include "d4all.h"
- #include "w4.h"
- #include "u4error.h"
-
- #include <string.h>
- #include <stdio.h>
-
-
- static FIELD fields[]=
- {
- { "TEST", 'N', 15, 0, 0 },
- } ;
-
-
- main( int argc, char **argv )
- {
- int i_ref, c ;
- long num_recs, i_rec, f_ref ;
- double d, neg ;
-
- #ifdef NO_HUGE
- #ifdef IS_386
- d4init() ;
- #else
- d4initialize( 4, 4, 20, 1000, 20000L ) ;
- #endif
- #else
- d4init() ;
- #endif
- w4clear(-1) ;
-
- if ( argc >= 2 )
- num_recs = c4atol( argv[1], strlen(argv[1]) ) ;
- else
- num_recs = 1000L ;
- w4( w4row(),0, "t4write - Number of Records:" ) ;
- w4long( w4row(),w4col(), num_recs, 6 ) ;
-
- d4create( "t4write2", 1, fields, 0 ) ;
- i_ref = i4index( "t4write2", "TEST", 0, 0 ) ;
-
- f_ref = f4ref( "TEST") ;
-
- d = 60000000.0 ;
- neg = -5.0 ;
-
- f4replace( f_ref, &d ) ;
-
- w4( w4row()+1,0, "Writing Rec:" ) ;
- c = w4col() ;
-
- for ( i_rec = 1L; i_rec <= num_recs; i_rec++ )
- {
- w4long( w4row(),c, i_rec, 6 ) ;
- d4write(0L) ;
- }
-
- if ( i4check(i_ref) != 0L )
- {
- u4error( 0, "t4write: after writes, i4check()", (char *) 0 ) ;
- w4exit(1) ;
- }
-
- d -= 100000.0 ;
-
- w4( w4row()+1,0, "Replacing Record: " ) ;
- c = w4col() ;
-
- for ( i_rec = 1; i_rec <= num_recs; i_rec++ )
- {
- w4long( w4row(),c, i_rec, 6 ) ;
-
- if ( d4seek( &d ) != 2 )
- {
- u4error( 0, "t4write: d4seek()", (char *) 0 ) ;
- w4exit(1) ;
- }
-
- if ( d4recno() != i_rec )
- {
- u4error( 0, "t4write: d4seek()", (char *) 0 ) ;
- w4exit(1) ;
- }
-
- f4replace( f_ref, &neg ) ;
-
- if ( d4write ( d4recno() ) != 0 )
- {
- u4error( 0, "t4write: d4write", (char *) 0 ) ;
- w4exit(1) ;
- }
- }
-
- if ( i4check(i_ref) != 0L )
- {
- u4error( 0, "t4write: after replaces, i4check()", (char *) 0 ) ;
- w4exit(1) ;
- }
-
- d4close_all();
-
-
- #ifdef H4TEST
- {
- int rc ;
- d4init_undo() ;
- rc = h4free_check(32000) ;
- d4init() ;
- if ( rc != 0 )
- {
- u4error( 0, "t4write: Memory items not freed", (char *) 0 );
- w4exit(1) ;
- }
- }
- #endif
-
- w4handle(1) ;
- w4( w4row()+1,0, "t4write: SUCCESS" ) ;
- w4exit(0) ;
- }
-