Daniel Lee · May 26, 2020

ClassMethod with global parameter undefined when attempting to Order

I have a class method that accepts a global parameter but when I attempt to order this global, the global name is listed as undefined. I can execute $DATA(pGlobalName) successfully.

ClassMethod ExamineGlobal(pGlobalName As %Global)
   set gStatus=$DATA(pGlobalName) ; returns 1 
    write "This is the global name: "_pGlobalName
   set gmin=$ORDER(pGlobalName("")) ; here pGlobalName is undefined

In debug mode, data returns 1 for a valid global with no descendants. This is expected.

However, when I call $ORDER, it shows <UNDEFINED> for pGlobalName. My guess is that ORDER is operating on the local variable pGlobalName instead of its value? How can I 'dereference' the variable name so that the Order method operates on its value rather than the name itself?

I want to use this for an array of seventy globals and would rather have o single method call to perform work for each global rather than having to explicitly write code for every global. 

Thank you.

I should mention that I am using Cache Ensemble 2010. 

1 0 3 95


with set gStatus=$DATA(pGlobalName)  you check the existence of your call parameter

but set gStatus=$DATA(@pGlobalName) check the existence of your Global
to go for the Global you require indirection  therefore set gmin=$ORDER(@pGlobalName@(""))
will meet your expectations

EXCELLENT! That is exactly what I needed. 

Also, you correctly observed that $DATA(pGlobalName) was only evaluating the local parameter and not its value. My return value is now 10. 

Thank you Robert.