FLOCK( ) Function Example

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE products  && Opens products table
SET REPROCESS TO 3 SECONDS
SELECT * FROM products INTO TABLE newprods

IF FLOCK( )
   *** New product initialization ***
   REPLACE ALL in_stock  WITH 0.00
   REPLACE ALL on_order WITH 0.00
   WAIT 'Initialization Complete' WINDOW NOWAIT
ELSE
   *** File is locked, warn user ***
   WAIT WINDOW 'Unable to open products file; try again later!' NOWAIT
ENDIF

BROWSE FIELDS in_stock, on_order && Displays newprods table
USE
ERASE newprods.dbf