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

  1.  
  2. /* i4select.c   (c)Copyright Sequiter Software Inc., 1987-1990
  3.  
  4.    Selects the active index file for the current database.
  5.  
  6.    Returns
  7.        0   Success
  8.       -1   Error
  9. */
  10.  
  11. #include "d4all.h"
  12. #include "u4error.h"
  13.  
  14. extern  INDEX  *v4index ;
  15. extern  BASE   *v4base ;
  16. extern  int     v4cur_base ;
  17.  
  18. i4seek_ref()
  19. {
  20.    int  i_ref ;
  21.  
  22.    if ( v4cur_base < 0 )  return -1 ;
  23.    i_ref =  v4base[v4cur_base].current_index ;
  24.    if ( i_ref < 0 )  i_ref =  v4base[v4cur_base].index_ref ;
  25.  
  26.    return i_ref ;
  27. }
  28.  
  29.  
  30. i4select( int index_ref )
  31. {
  32.    int index_on, previous_ref ;
  33.    BASE *base_ptr ;
  34.  
  35.    base_ptr =  d4ptr() ;
  36.    previous_ref =  base_ptr->current_index ;
  37.  
  38.    i4unselect() ;
  39.    if ( index_ref < 0 )  return( previous_ref ) ;
  40.  
  41.    index_on =  base_ptr->index_ref ;
  42.    while ( index_on >= 0)
  43.    {
  44.       if (index_on == index_ref )
  45.       {
  46.      base_ptr->current_index =  index_ref ;
  47.      return( previous_ref ) ;
  48.       }
  49.       index_on =  v4index[index_on].prev ;
  50.    }
  51.  
  52.    return( previous_ref ) ;
  53. }
  54.  
  55.  
  56. void i4unselect()
  57. {
  58.    if ( d4ptr()->current_index >= 0 )  i4unlock( d4ptr()->current_index ) ;
  59.    d4ptr()->current_index =  -1 ;
  60. }
  61.  
  62.  
  63.