[an error occurred while processing this directive]
 | Forms Processor Advanced Commands |
Contents
Index of Commands
Search the Forms Processor Docs
set_lock/free_lock
Sets or removes an exclusive file access lock. (Used only in rare cases when you
write a custom multi-step file update script.
Normally, you would not use this parameter, as the form processor handles coordination of multiple simultaneous forms submissions for you automatically when
simply inserting data into (or appending data to) an existing file).
- &set_lock("filename");
&free_lock("filename");
-
- filename - the name of the file which you want to
obtain or release exclusive read and write access to.
- Upon successfully locking the file, set_lock returns 0. If set_lock
is unabled to obtain a lock after 30 seconds, it will return -1.
Example:
# get exclusive access
if (&set_lock("form/count.dat") != 0)
format screen
This service is very busy - please try again!
.
else
&slurp("counter","form/count.dat");
$counter=$counter+1;
format screen
This form has been submitted $counter times.
.
# now save the new value of the counter
format file form/count.dat overwrite
$counter
.
# release the lock
&free_lock("form/count.dat");
endif
See also:
Detailed explanation for the example above
[an error occurred while processing this directive]