Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - arlock() lock the current record in an alias http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 arlock()            Lock the current record in an alias
------------------------------------------------------------------------------
 Declaration
   database.hdr

 Syntax
   func logical arlock extern
   param alias sDatabase

 Arguments
   sDatabase is the alias to manipulate.

 Return
   A logical indicating the success of operation.

 Description
   The arlock() function attempts to lock the current record in the specified
   alias sDatabase. If the lock is successful, arlock() returns .t.. Any
   locks, record or file currently assigned to sDatabase are released
   and, if arlock() is unsuccessful, the locks are not restored.

   The use of rlock() or arlock() is recommended when updating a record
   with the get/read, delete, recall, or replace (:=) commands.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   func logical WaitRecord
   param alias sAlias, value int nSecs
   // A "wait for a record" function. Waits for nSecs seconds for a record.
   vardef
      long gEnd
   enddef
   gEnd := seconds() + nSecs
   repeat
      if arlock( sAlias )
         return( .t. )
      endif
   until seconds() > gEnd
   return( .f. )
   endfunc
   
   proc Test_arlock
   /*
   Lock a record prior to a get command. Be sure the time between the get and
   the read is minimal, because another process could be waiting for the record.
   */
   open sTest
   clear
   if WaitRecord( sTest, 5 )
      @ 1, 1 say "Name: " get sTest->lastname
      read
      unlock
      ? sTest->lastname
   else
      ? "Unable to access record"
   endif
   endproc

   proc main
   Test_arlock()
   endproc

See Also: aflock() flock() rlock() unlock

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