How to have a different conditional check for a null object and locked object?
I have a list type data object, that has both null entries and locked entries. While iterating through the list items using GetAt() function, a locked item is satisfying the not null condition. But I need a different conditional statement for null items and locked items.
Discussion (3)0
Comments
Do you have a code snippet for us? Something like
write mylist.%IsA("%ListOfDataTypes") --> 1set item = mylist.%GetAt(2)
//// Now the big question: what do you (want to) do with this item?//// do you try to lock a global: lock ^myGlobal(item) ?// do you try to open (a possible locked) Object: set obj=##class(some.class).%OpenId(item [,4]) ?// something else?How do you recognize LOCKED items ?
How do you LOCK items ?
Well, you already have a null check.
To check if the object is locked just try to acquire exclusive lock with no wait, so it's enough to call %AcquireLock.