Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see How to Migrate to InterSystems IRIS, available on the WRC Distributions page (login required).

Lock Command and $Test

In ObjectScript, the $Test system variable gets set when the system runs certain commands, such as Lock, when used with a timeout. The value of this variable is either 0 (false) or 1 (true).

You can use a timeout (in seconds) on Lock, so that it doesn't wait forever. If the Lock is unsuccessful in the allotted time, the system sets the $Test variable to 0. You can then check the value of $Test.

SAMPLES>lock +^x(1):5

SAMPLES>if ('$test) { write "Try again later." }
Try again later.
SAMPLES>
Feedback