Search code examples
intersystems-cache

Can I return the tag and routine name?


I am working on a code "maintenance" idea where I would like to populate a global when routines are accessed and by who. I can pull the current routine name using $t(+0) or $ZNAME, but what about the current tag and/or line offset? Is there a way so I can put a standard line in the routines I want to track?


Solution

  • Rob, you can get these information from $STACK.

    If you call your own tracking function, you get the calling stack info like this:

    W $STACK($STACK(-1)-1,"PLACE")
    

    zExecute+2^%Studio.General.1 +1

    Take a look at the Caché ObjectScript Reference for $STACK for detailed description and examples.