home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / D4SEEK_K.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  965 b   |  48 lines

  1.  
  2. /*  d4seek_k.c   (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  3.  
  4.     Locates and reads the record.
  5.  
  6.     Returns
  7.  
  8.        0 Success
  9.        1 Inexact Find
  10.        2 On record after
  11.        3 EOF
  12.       -1 Error
  13. */
  14.  
  15. #include "d4all.h"
  16. #include "u4error.h"
  17.  
  18. extern  BASE  *v4base ;
  19. extern  INDEX *v4index ;
  20. extern  int    v4cur_base ;
  21.  
  22. d4seek_key(  int index_ref, void *key_ptr )
  23. {
  24.    int   rc, r_rc ;
  25.    BASE  *base_ptr ;
  26.  
  27.    base_ptr =  d4ptr() ;
  28.    if ( d4changed( base_ptr )  < 0 )  return -1 ;
  29.  
  30.    base_ptr->bof =  base_ptr->eof =  0 ;
  31.  
  32.    if ( (rc =  i4seek( index_ref, key_ptr)) < 0)  return rc ;
  33.  
  34.    if ( rc == 3)
  35.    {
  36.       d4blank() ;
  37.       base_ptr->rec_num =  d4reccount()+1L ;
  38.       if ( base_ptr->rec_num == 1L )  base_ptr->bof =  1 ;
  39.       base_ptr->eof =  1 ;
  40.       return( 3 ) ;
  41.    }
  42.  
  43.    r_rc =  d4read( i4key(index_ref)->rec_num) ;
  44.    if ( r_rc < 0 )  return r_rc ;
  45.  
  46.    return rc ;
  47. }
  48.