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 / I4SELECT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-14  |  1.2 KB  |  64 lines

  1.  
  2. /* i4select.c   (c)Copyright Sequiter Software Inc., 1987, 1988, 1989
  3.  
  4.    Selects the active index file for the current database.
  5.  
  6.    Returns
  7.        0   Success
  8.       -1   Error
  9. */
  10.  
  11. #include "d4base.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( index_ref )
  31. int       index_ref ;
  32. {
  33.    int index_on, previous_ref ;
  34.    BASE *base_ptr ;
  35.  
  36.    base_ptr =  d4ptr() ;
  37.    previous_ref =  base_ptr->current_index ;
  38.  
  39.    i4unselect() ;
  40.    if ( index_ref < 0 )  return( previous_ref ) ;
  41.  
  42.    index_on =  base_ptr->index_ref ;
  43.    while ( index_on >= 0)
  44.    {
  45.       if (index_on == index_ref )
  46.       {
  47.      base_ptr->current_index =  index_ref ;
  48.      return( previous_ref ) ;
  49.       }
  50.       index_on =  v4index[index_on].prev ;
  51.    }
  52.  
  53.    return( previous_ref ) ;
  54. }
  55.  
  56.  
  57. void i4unselect()
  58. {
  59.    if ( d4ptr()->current_index >= 0 )  i4unlock( d4ptr()->current_index ) ;
  60.    d4ptr()->current_index =  -1 ;
  61. }
  62.  
  63.  
  64.