lock-file <file path> id <lock id> status <status>Copied!
%% /locktest public // Get application home directory get-app directory to dir // Create lock file name write-string fname @<<p-out dir>>/.lock end-write-string // Enter loop in which something is done, OR, program waits for others to complete their work before doing its own set-number lockid start-loop // Attempt to lock file lock-file fname id lockid status lockst // Check the status of locking if-true lockst equal GG_OKAY // File successfully locked, simulate working for 20 seconds @WORKING pause-program 20000 @DONE // Exit while loop break-loop else-if lockst equal GG_ERR_FAILED // Another process holds the lock, wait, try again for 1 second pause-program 1000 @WAITING continue-loop else-if lockst equal GG_ERR_OPEN or lockst equal GG_ERR_INVALID // Errors @BAD LOCK exit-handler end-if end-loop // Once done, unlock file unlock-file id lockid %%Copied!