home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / NETUSE.PRG < prev    next >
Encoding:
Text File  |  1991-07-05  |  2.9 KB  |  99 lines

  1. /*
  2.     Program: NET_USE()
  3.     System: GRUMPFISH LIBRARY
  4.     Author: Greg Lief
  5.     Copyright (c) 1988-90, Greg Lief
  6.     Clipper 5.x Version
  7.     Compile instructions: clipper netuse /n/w/a
  8.     Opens files for exclusive and shared use in multi-user systems
  9. */
  10.  
  11. //───── begin preprocessor directives
  12.  
  13. #include "grump.ch"
  14. #include "inkey.ch"
  15.  
  16. //───── end preprocessor directives
  17.  
  18. function net_use(mfile, excl_use, ndx1,ndx2,ndx3,ndx4,ndx5,ndx6,ndx7,ndx8)
  19. local firstloop := .t., ret_val := .f., box_no, oldcolor, waitmsg, buffer, ;
  20.       oldscrn, malias, ptr, key := 0
  21. default excl_use to .f.
  22. //───── if they passed the word "alias" as part of filename,
  23. //───── use a different alias
  24. if ( ptr := at("ALIAS", upper(mfile)) ) > 0
  25.    malias := trim(substr(mfile, ptr + 6))
  26.    mfile := substr(mfile, 1, ptr - 1)
  27. else
  28.    malias := ''
  29. endif
  30. waitmsg := mfile + '.dbf'  // used in kaleidoscope if user has to wait
  31. do while key != K_ESC
  32.    if excl_use
  33.       if ! empty(malias)
  34.          use (mfile) new exclusive alias &malias
  35.       else
  36.          use (mfile) new exclusive
  37.       endif
  38.    else
  39.       if ! empty(malias)
  40.          use (mfile) new alias &malias
  41.       else
  42.          use (mfile) new
  43.       endif
  44.    endif
  45.    if ! neterr()     // file opened successfully - now open indexes
  46.       ret_val := .t.
  47.       if ndx1 != NIL
  48.          do case
  49.             case ndx2 == NIL
  50.                set index to (ndx1)
  51.             case ndx3 == NIL
  52.                set index to (ndx1), (ndx2)
  53.             case ndx4 == NIL
  54.                set index to (ndx1), (ndx2), (ndx3)
  55.             case ndx5 == NIL
  56.                set index to (ndx1), (ndx2), (ndx3), (ndx4)
  57.             case ndx6 == NIL
  58.                set index to (ndx1), (ndx2), (ndx3), (ndx4), (ndx5)
  59.             case ndx7 == NIL
  60.                set index to (ndx1), (ndx2), (ndx3), (ndx4), (ndx5), (ndx6)
  61.             case ndx8 == NIL
  62.                set index to (ndx1), (ndx2), (ndx3), (ndx4), (ndx5), (ndx6), ;
  63.                             (ndx7)
  64.             otherwise
  65.                set index to (ndx1), (ndx2), (ndx3), (ndx4), (ndx5), (ndx6), ;
  66.                             (ndx7), (ndx8)
  67.          endcase
  68.       endif
  69.       exit
  70.    else
  71.       if firstloop
  72.          if yes_no('File ' + mfile + ' cannot be opened at this time', ;
  73.                    'Would you like to wait')
  74.             oldscrn := savescreen(0, 0, 24, 79)
  75.             kaleid(.t., waitmsg)
  76.             firstloop := .f.
  77.          else
  78.             exit
  79.          endif
  80.       else
  81.          kaleid(.f., waitmsg)
  82.       endif
  83.    endif
  84.    key := lastkey()
  85. enddo
  86. if ! firstloop
  87.    setcolor(oldcolor)
  88.    restscreen(0, 0, 24, 79, oldscrn)
  89.    if ret_val   // file opened successfully - give user aural feedback
  90.       CHARGE
  91.    endif
  92. endif
  93. return (ret_val)
  94.  
  95. * end function Net_Use()
  96. *--------------------------------------------------------------------*
  97.  
  98. * eof netuse.prg
  99.