How do I retrieve the name of the first GLOBAL from within the GLOBAL directory?
How do I retrieve the name of the first GLOBAL from within the GLOBAL directory?
Should I use some syntax with $Order or $Query or is there another way?
Discussion (3)1
Comments
Hi Pedro,
You can use :
Write $Order(^$GLOBAL(""))https://docs.intersystems.com/iris20231/csp/docbook/Doc.View.cls?KEY=RC…
Hi, look at ^$GLOBAL
GLOB
SET NAME=""
WRITE !,"The following globals are in ",$NAMESPACE
FOR I=1:1 {
SET NAME=$ORDER(^$GLOBAL(NAME))
WRITE !,NAME
QUIT:NAME=""
SET GLOBAL(I)=NAME
}
WRITE !,"All done"
QUITI hope it is what you need
As others already wrote,
write $order(^$GLOBAL(""))gives you the first global name accessible from a given namespace. Usually, this will be a percent-global (^%...) but if you want to get the first (or all) global, which resides in a given database, the do the same as above but with extended global access
set dir = "^^c:\databases\mydb\" // "^^" and "the path to your CACHE/IRIS.dat file"
write $order(^$|dir|GLOBAL(""))