PicLan-IP provides a utility function to allow applications to set standard item locks from within a web application. Theoretically, any application can use this utility subroutine, but only web applications should need it. There are several rules regarding locks that should be mentioned first.
You must also insure that you never release locks that your application did not set. The PicLan-IP Web Server thread processes typically run with several item-locks that are continually set. It is important that you application not release these locks with a general RELEASE statement.
On the web page where the lock is set:
CALL PLW.ILOCK('LOCK',file,item,timeout,res,r2)This call will set a lock. Your program supplies file, item, and timeout values. file is the name of the file in which the lock resides. item is the item-id of the item to lock. timeout is the number of seconds that the lock will be held. After this period of time, the lock will be automatically released.
The results to this call are res, and r2. res contains a string:
CALL PLW.ILOCK('CHECK',handle,timeout,'',res,r2)This call will check to see if you still 'own' a lock. Because locks time out, you should always check to see if the lock is still yours before updating any data. Your program supplies handle, and timeout. handle is the returned handle from a previous call to PLW.ILOCK('LOCK'...) and was presumably saved in a form's hidden input field, cookie, or other state area. timeout, is the number of additional seconds that you wish the lock held for. Be sure to set timeout to a large enough value for you to complete your update.
The results of this call are res, and r2. res contains a string:
CALL PLW.ILOCK('UNLOCK',handle,'','',res,r2)This call will release a lock that was previously set. Your program supplies handle which was previously returned in r2 from a previous call to PLW.ILOCK('LOCK'...).
The results of this call are res, and r2. res contains a string: