Wednesday, February 10, 2010

Lock, Save and Unlock Methods in Capture professional

The Lock, Unlock, and Save methods of a RepObject are used to make changes to the RepObject.To change a RepObject you must lock it, make the change, save it, and then unlock it. If you try to lock a RepObject already locked by another user, you will receive an error. The following code renames a RepObject:

Dim oBatch as RepObject
If oBatch.Lock then
oBatch.Name = “newname”
oBatch.Save
oBatch.Unlock
EndIf

The Lock, Save and Unlock methods each return a boolean value indicating success or failure. Locking a RepObject locks all the children of that RepObject. Saving a RepObject saves all of the children of that RepObject. Each call to the Lock method must eventually be matched with a call to the Unlock method by the same user before a RepObject is fully unlocked. The RepObject manages an internal lock count that is incremented by the Lock method and decremented by the Unlock method. The RepObject is deemed no longer locked when this lock count reaches zero. For example, if an application calls the Lock method twice on a given RepObject, it must eventually call Unlock twice on the same RepObject

No comments: