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

  1. /*
  2.     Program: FILELOCK()
  3.     System: GRUMPFISH LIBRARY
  4.     Author: Greg Lief
  5.     Copyright (c) 1988-90, Greg Lief
  6.     Clipper 5.x Version
  7.     Compile instructions: clipper filelock /n /w /a
  8.  
  9.     Attempts to lock file in multi-user environment
  10. */
  11.  
  12. //───── begin preprocessor directives
  13.  
  14. #include "grump.ch"
  15. #include "inkey.ch"
  16.  
  17. //───── end preprocessor directives
  18.  
  19. function filelock
  20. local box_no, buffer, firstloop, ret_val := .f., waitmsg, oldscrn, key := 0
  21. if len(alias()) > 0   // hey, must have a database in use, eh Joe?
  22.    waitmsg := alias() + '.dbf'   // used in kaleidoscope if user decides to wait
  23.    firstloop := .t.
  24.    do while key != K_ESC .and. ! ret_val
  25.       if flock()
  26.          ret_val := .t.
  27.       elseif firstloop
  28.          firstloop := .f.
  29.          if yes_no('Cannot lock ' + waitmsg + ' at this time', ;
  30.                    'Would you like to wait')
  31.             oldscrn := savescreen(0, 0, maxrow(), maxcol())
  32.             kaleid(.t., waitmsg)
  33.          else
  34.             exit
  35.          endif
  36.       else
  37.          kaleid(.f., waitmsg)
  38.          key := lastkey()
  39.       endif
  40.    enddo
  41.    if ! firstloop
  42.       restscreen(0, 0, maxrow(), maxcol(), oldscrn)
  43.       if ret_val    // file locked successfully - give user aural feedback
  44.          CHARGE
  45.       endif
  46.    endif
  47. endif
  48. return (ret_val)
  49.  
  50. * end function FileLock()
  51. *--------------------------------------------------------------------*
  52.  
  53. * eof filelock.prg
  54.