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

 Syntax
   func logical flock extern

 Arguments
   None.

 Return
   A logical indicating the success of operation.

 Description
   flock() attempts to lock the current alias. If the database file is
   successfully locked, flock() returns .t.. Any record or file lock
   assigned to the current alias is released and, if flock() is
   unsuccessful, the locks are not restored.

   All files associated with the current alias are locked, including index
   and memo files.

   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_flock
   vardef
       char cAnswer
   enddef
   open sTest shared
   ? "Number of records", istr( reccount() )
   do while .not. eof()                 // delete some records
      if recno() > 80
         delete()
      endif
      skip
   enddo
   accept "Pack database?" to cAnswer
   if cAnswer $ "Yy"
      if flock()                        // lock database prior to packing
         ? "Packing database"
         pack
         ? "Records remained", istr( reccount() )
      else
         ? "Unable to get database."
         ? "Please try later..."
      endif
      wait
   endif
   endproc

   proc main
   Test_flock()
   endproc

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

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