home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / D4BOTTOM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-19  |  1.2 KB  |  62 lines

  1.  
  2. /*  d4bottom.c   (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  3.  
  4.     Reads the top bottom record of the database.
  5.     Sets the current record to the bottom record.
  6.  
  7.     Returns
  8.        0 Success
  9.        3 EOF
  10.       -1 Error
  11.  
  12. */
  13.  
  14. #include "d4all.h"
  15. #include "u4error.h"
  16.  
  17. extern  BASE  *v4base ;
  18. extern  INDEX *v4index ;
  19. extern  int    v4cur_base ;
  20.  
  21.  
  22. d4bottom()
  23. {
  24.    BASE *base_ptr ;
  25.    int   rc ;
  26.  
  27.    if ( v4cur_base < 0 ) 
  28.    {
  29.       u4error( E_D_MISSING, (char *) 0 ) ; 
  30.       return( -1 ) ;
  31.    }
  32.  
  33.    base_ptr =  v4base + v4cur_base ;
  34.    base_ptr->eof =  base_ptr->bof =  0 ;
  35.  
  36.    if ( base_ptr->current_index >= 0)
  37.    {
  38.       rc =  i4bottom( base_ptr->current_index ) ;
  39.       if ( rc < 0 )  return rc ;
  40.       if ( rc == 0 )
  41.       {
  42.      rc = d4go( i4key(base_ptr->current_index)->rec_num ) ;
  43.      if ( rc == 1 ) 
  44.      {
  45.         u4error( E_I_RECORD, v4index[base_ptr->current_index].name, (char *) 0) ;
  46.         return -1 ;
  47.      }
  48.      return( rc ) ;
  49.       }
  50.    }
  51.    else
  52.       if ( d4reccount() > 0)
  53.      return( d4go( d4reccount()) ) ;
  54.  
  55.    d4blank() ;
  56.    base_ptr->rec_num = d4reccount()+1L ;
  57.    base_ptr->bof =  base_ptr->eof =  1 ;
  58.  
  59.    return( 3) ;
  60. }
  61.  
  62.