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>rec_lock() attempt to lock the current record locks.prg</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Rec_lock()     Attempt to lock the current record         Locks.prg


Syntax:        Rec_lock(<seconds>)

Argument:      <seconds> is the number of seconds to attempt to
               obtain the record lock.  A value of zero forces the wait
               to be indefinite.

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


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

   IF Rec_lock(5)
      REPLACE Price WITH newprice
   ELSE
      ? "Record not available"
   ENDIF


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

   FUNCTION Rec_lock
   PARAMETERS wait
   PRIVATE forever

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

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

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

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

   ENDDO
   RETURN (.F.)                 && not locked

.

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