home *** CD-ROM | disk | FTP | other *** search
-
- /* d4top.c (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
-
- Reads the top record of the database.
- Sets the current record to the top record.
- Uses the active record ordering.
-
- Returns
- 0 Success
- 3 EOF
- -1 Error
-
- */
-
- #include "d4all.h"
- #include "u4error.h"
-
- extern BASE *v4base ;
- extern INDEX *v4index ;
- extern int v4cur_base ;
-
- d4top()
- {
- BASE *base_ptr ;
- int rc ;
-
- if ( v4cur_base < 0 )
- {
- u4error( E_D_MISSING, (char *) 0 ) ;
- return( -1 ) ;
- }
-
- base_ptr = v4base + v4cur_base ;
- base_ptr->bof = base_ptr->eof = 0 ;
-
- if ( base_ptr->current_index >= 0)
- {
- rc = i4top( base_ptr->current_index ) ;
- if ( rc < 0 ) return rc ;
- if ( rc == 0)
- {
- rc = d4go( i4key(base_ptr->current_index)->rec_num ) ;
- if ( rc == 1 )
- {
- u4error( E_I_RECORD, i4name(base_ptr->current_index), (char *) 0) ;
- return -1 ;
- }
- return( rc ) ;
- }
- }
- else
- {
- if ( d4reccount() >= 1 )
- return( d4go( 1L) ) ;
- }
-
- /* EOF - No Records */
- d4blank() ;
- base_ptr->rec_num = d4reccount()+1L ;
- base_ptr->bof = base_ptr->eof = 1 ;
-
- return( 3 ) ;
- }
-
-
-