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 - aflock() lock a database file http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 aflock()            Lock a database file
------------------------------------------------------------------------------
 Declaration
   database.hdr

 Syntax
   func logical aflock extern
   param alias sDatabase

 Arguments
   sDatabase is the alias to manipulate.

 Return
   A logical indicating the success of operation.

 Description
   aflock() attempts to lock sDatabase, including all index and
   memo files associated with it. If the database file could be
   successfully locked, aflock() returns .t.. Any record or file lock
   currently assigned to sDatabase is released and, if aflock()
   was unsuccessful, the locks will not be restored.

   The use of flock() or aflock() is recommended when doing
   operations (reindex, pack, zap) that affect the database as a whole,
   or when updating multiple records using the append from, delete,
   recall, or replace commands.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   proc Test_aflock
   //  Lock a database prior to using count to ensure a good report
   vardef
      long nCountTotal
   enddef
   nCountTotal := 0
   open sTest
   if aflock( sTest )
      ! sTest count all for sTest->balance > 10000 to nCountTotal
   endif
   ! sTest unlock
   ? "Number of records with balance greater than 10,000 is", istr( nCountTotal )
   endproc

   proc main
   Test_aflock()
   endproc

See Also: arlock() flock() unlock

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