Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>fil_lock() try to lock the current database file locks.prg</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Fil_lock()     Try to lock the current database file   Locks.prg


Syntax:        Fil_lock(<seconds>)

Argument:      <seconds> is the numbers of seconds to wait for the
               current database file to become available.  A values of
               zero means wait indefinitely.

Returns:       Fil_lock() returns true (.T.) if the lock is obtained;
               otherwise it returns false (.F.).


--------------------------------- Example ------------------------------

   IF Fil_lock(5)
      REPLACE ALL Price WITH Price * 1.1
   ELSE
      ? "File not available"
   ENDIF


--------------------------------- Source Code ------------------------------

   FUNCTION Fil_lock
   PARAMETERS wait
   PRIVATE forever

   IF FLOCK()
      RETURN (.T.)              && locked
   ENDIF

   forever = (wait = 0)
   DO WHILE (forever .OR. wait > 0)

      INKEY(.5)                 && wait 1/2 second
      wait = wait - .5

      IF FLOCK()
         RETURN (.T.)           && locked
      ENDIF

   ENDDO
   RETURN (.F.)                 && not locked


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson