home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CODE4-1.ZIP / SOURCE.ZIP / D4BOTTOM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-14  |  1.2 KB  |  59 lines

  1.  
  2. /*  d4bottom.c   (c)Copyright Sequiter Software Inc., 1987, 1988, 1989.  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 "d4base.h"
  15. #include <string.h>
  16. #include "u4error.h"
  17.  
  18. extern  BASE  *v4base ;
  19. extern  INDEX *v4index ;
  20. extern  int    v4cur_base ;
  21.  
  22.  
  23. d4bottom()
  24. {
  25.    BASE *base_ptr ;
  26.    int   rc ;
  27.  
  28.    base_ptr =  v4base + v4cur_base ;
  29.    if ( v4cur_base < 0 ) 
  30.    {
  31.       u4error( E_D_MISSING, (char *) 0 ) ; 
  32.       return( -1 ) ;
  33.    }
  34.  
  35.    if ( base_ptr->current_index >= 0)
  36.    {
  37.       rc =  i4bottom( base_ptr->current_index ) ;
  38.       if ( rc < 0 )  return -1 ;
  39.       if ( rc == 0 )
  40.       {
  41.      rc = d4go( b4key(base_ptr->current_index)->rec_num ) ;
  42.      if ( rc == 1 ) 
  43.      {
  44.         u4error( E_I_RECORD, v4index[base_ptr->current_index].name, (char *) 0) ;
  45.         return -1 ;
  46.      }
  47.      return( rc ) ;
  48.       }
  49.    }
  50.    else
  51.       if ( d4reccount() > 0)
  52.      return( d4go( d4reccount()) ) ;
  53.  
  54.    memset( base_ptr->buffer, (int) ' ', (size_t) base_ptr->buffer_len ) ;
  55.    base_ptr->rec_num = -1 ;
  56.    return( 3) ;
  57. }
  58.  
  59.