Question Norman W. Freeman · Aug 4, 2023

How to create a global node, without knowing the number of keys in advance ?

Hello,
I would like to do the following :

set name = $name(^A)
for i=1:1:10
{
    set$qsubscript(name, i) = "TEST"_i //dream code that does not work
}
set @name = ""//will create ^A("TEST1", "TEST2", "TEST3", ... , "TEST10") = ""

Unfortunately, unlike $PIECE(), $QSUBSCRIPT() is not bidirectional.

Is there a way to do what I described, in a clean way ? (something supported by the system) 

I would like to avoid :

- using a custom made solution (eg: appending keys one by one to a string, adding commas when needed) unless it's failproof (eg: can deal with commas in keys, non string keys, ...)
- having code that do multiple writes to database (eg: code that create ^A("TEST1") then ^A("TEST1", "TEST2"), ... sequentially. That's inefficient and not what I want.

Product version: IRIS 2021.1
$ZV: IRIS for Windows (x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:39:22 EDT

Comments

Julius Kavay · Aug 4, 2023
set name = $name(^A)
for i=1:1:10 { set name = $name(@name@("TEST"_i)) }
set @name=""
0
Julius Kavay  Aug 4, 2023 to Julius Kavay

By the way, you can also "shorten" a given node and start over...

// from the above example,// name = ^A("TEST1","TEST2", ... "TEST10")// now we take that global with the first two subscriptsset name = $name(@name,2)
// and add new subscriptsset name = $name(@name@(3333,4444))
set @name = "new data"

Try it and then ZWRITE ^A  to see the effect

0
Joel Solon · Aug 7, 2023

Would it be possible for you to share your reason for wanting to do this with the community?

0
Norman W. Freeman  Aug 12, 2023 to Joel Solon

For debugging reasons : I wanted to dump the stack to a global, to find out from where some piece of code was called.

0
Robert Cemper  Aug 12, 2023 to Norman W. Freeman

there is a standard utility %ETN that writes such logs with the stack 
and all other $system variables into the global ERRORs
if you call it by LOG^%ETN it does a kind of snapshot
details here  take a look
 

0