Question
· Sep 3, 2019

Name of variable after being passed

Hi,

  I believe the healthshare Debug module did this (if you added it) but I no longer have access to Healthshare to look so am asking here.

 

Suppose I have;

Set fruit="apple"

set person="john"

d ..Something(fruit, person)

quit

 

ClassMethod Something(objs...) {

  ; Names of variables passed in

}

 

In side "Something" how can I see the original name of the variable passed in (i.e. know the variables passed in were called fruit and person and not just their values).

I appreciate this is rare and not idea but I am 90% sure the Healthshare debug service allowed this so there must be some obscure "call" somewhere to know (or I'm wrong).  Anyone know the trick?

Discussion (3)0
Log in or sign up to continue

The use case is some live software is not creating legacy index "sometime", logic looks good but some "combination" misses the index create.  In test works fine.  SO want to add lots of auditing and have a common call to an debug audit to record variables, objects etc.  Hence want to record the name of the variable used when calling the audit.

Anyway the $STACK pointed me at what I need and its all done and working...Thanks!

Hi Paul, there can be couple of possible solutions though. But a simple one is as follows:

Set fruit="apple"

set person="john"

NEW $ESTACK
Set tIindex = $ESTACK
Set ^VarIndex(tIindex,1) = "fruit"
Set ^VarIndex(tIindex,2) = "person"

d ..Something(fruit, person)

quit

ClassMethod Something(objs...) {

  ; Names of variables passed in

Set sIndex = $ESTACK - 1

$$$TRACE("First variable:  "_^VarIndex(sIndex,1)_"  Second variable: "_^VarIndex(sIndex,2))

}

Using this method even if you call 100 methods each time method will quit and return to main method $ESTACK will restore its initial value. In each method we will just decrement its value by 1 and can access previous value (original name) of each variable. Moreover by indexing we can access any original name randomly.

This way