Question Keerthi Mettu · Jul 21, 2023

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.

Comments

Julius Kavay · Jul 21, 2023

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?
0
Robert Cemper · Jul 22, 2023

How do you recognize LOCKED items ?
How do you LOCK items ?

0
Eduard Lebedyuk · Jul 22, 2023

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.

0