home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / EXAMPLES / X4MULTI.C < prev   
Encoding:
C/C++ Source or Header  |  1990-06-22  |  2.7 KB  |  129 lines

  1. /* (c)Copyright Sequiter Software Inc., 1987, 1988, 1989.  All rights reserved. */
  2.  
  3. /* List Using Multi-User Capabilities */
  4.  
  5. #include "d4base.h"
  6. #include "w4.h"
  7. #include "p4misc.h"
  8.  
  9. #ifndef NO_KBHIT
  10.    #include <conio.h>
  11. #endif
  12.  
  13. static  int  x4multi_list(void) ;
  14.  
  15. main( int argc, char **argv )
  16. {
  17.    d4init() ;
  18.    w4clear(-1) ;
  19.  
  20.    w4(0,0, "Database Multi-User File Listing Program" ) ;
  21.    w4(2,0, "(C) Sequiter Software Inc, 1988, 1989" ) ;
  22.    w4position( 4,0) ;
  23.  
  24.    if ( argc < 2 )
  25.    {
  26.       w4(4,0, "USAGE:  X4MULTI  DBF_FILE_NAME  [INDEX_FILE_NAME]" ) ;
  27.       w4cursor(5,0) ;
  28.       w4exit(1) ;
  29.    }
  30.  
  31.    if ( d4use( argv[1] ) < 0 )  w4exit(1) ;
  32.  
  33.    if ( argc > 2 )
  34.       i4open( argv[2] ) ;
  35.  
  36.    #ifdef TEST
  37.       w4handle(1) ;
  38.       while ( ! x4multi_list() )  ;
  39.    #else
  40.       x4multi_list() ;
  41.    #endif
  42.  
  43.    d4close_all() ;
  44.    w4exit(0) ;
  45. }
  46.  
  47.  
  48. static int  x4multi_list()
  49. {
  50.    int   rc, j, hand, len, row ;
  51.    long  field_ref ;
  52.  
  53.    if ( (rc =  d4top()) < 0)  return -1 ;
  54.    d4unlock(-1L) ;
  55.  
  56.    hand =  w4handle( -2 ) ;
  57.  
  58.    while ( rc == 0 )
  59.    {
  60.       if ( (rc = x4filter_do()) < 0 )  return -1 ;
  61.       if ( rc )
  62.       {
  63.          if ( (rc = d4skip(1L)) < 0 )  return -1 ;
  64.          d4unlock(-1L) ;
  65.  
  66.      #ifndef NO_KBHIT
  67.      if ( kbhit() )
  68.         if ( g4char() == 27)  return 1 ;
  69.      #endif
  70.          continue ;
  71.       }
  72.  
  73.       row =  w4row()+1 ;
  74.       if ( w4col() == 0 )  row-- ;
  75.  
  76.       if ( hand < 0 )
  77.       {
  78.          if ( row >= w4height(-1) -1 )
  79.          {
  80.             w4( w4height(-1) -1,0, "Press any key to continue ... " ) ;
  81.             w4cursor( w4row(), w4col() ) ;
  82.             if ( g4char() == 27 )  return 1 ;
  83.  
  84.             row =  0 ;
  85.             w4clear(0) ;
  86.          }
  87.          else
  88.             w4position( row, 0 ) ;
  89.       }
  90.       else
  91.          w4position( row, 0 ) ;
  92.  
  93.       for ( j=1; j <= f4num_fields(); j++ )
  94.       {
  95.          field_ref =  f4j_ref(j) ;
  96.          if ( f4type(field_ref) == 'M' )  continue ;
  97.  
  98.          len =  f4width( field_ref ) ;
  99.          if ( w4col()+len+2 > w4width(-1) )
  100.          {
  101.             len =  w4width(-1) - w4col() ;
  102.             if ( len > f4width(field_ref) )  len =  f4width(field_ref) ;
  103.  
  104.             w4num( row,w4col(), f4ptr(field_ref), len ) ;
  105.             break ;
  106.          }
  107.  
  108.          w4num( row,w4col(), f4ptr(field_ref), len ) ;
  109.          w4position( row, w4col()+2 ) ;
  110.       }
  111.  
  112.       if ( (rc = d4skip(1L)) < 0 )  return -1 ;
  113.       d4unlock(-1L) ;
  114.  
  115.       #ifndef NO_KBHIT
  116.       if ( kbhit() )
  117.      if ( g4char() == 27 )  return 1 ;
  118.       #endif
  119.    }
  120.  
  121.    d4unlock(-1L) ;
  122.  
  123.    if ( hand <= 0 )
  124.       w4cursor( w4height(-1) -2, 0 ) ;
  125.  
  126.    return 0 ;
  127. }
  128.  
  129.