How to write at the end of a global ? (last node)
I have a global with multiple nodes :
^A("ABC") = ""
^A("DEF") = ""
^A(123) = ""How to create a new single node in that global, in a way it's always at the end of the global (eg: this will be the very last node being enumerated)
I end up with this code but maybe there is a cleaner and simpler approach :
set ^A($char(65535)) = "" //should be bigger than any character insertedI only need to write it once, this code is not intended to be used in a loop or something, just to add something at the end (like a footer).
Usually, the naked global would contains the key of the last node, but that's not something I can do in this case (my procedure is called by legacy code that I have no control over)
set ^A = 1000
set ^A($I(^A)) = "" //will do set ^A(1001) = ""Comments
One option could be:
Set last=$o(^A(""),-1)
Set ^A(last_"z")="new last value"
In fact you can concatenate anything, not necessarily a "z"..
If the first subscript is always numeric, then:
Set last=$o(^A(""),-1)
Set ^A(last+1)="new last value"
The idea of
set ^A($char(65535)) = ""Looks good at first sight, but this might be the next follower
set ^A($char(65535),0) = ""