Menu

How to obtain the last global reference?

Help
2001-05-31
2001-07-11
  • John Murray

    John Murray - 2001-05-31

    On other M implementations there's an svn called $ZREFERENCE (abbreviated to $ZR). This allows the programmer to discover the last global reference that was accessed by the job. There doesn't seem to be an equivalent in GT.M.

    It's sometimes important for a subroutine or function to leave the naked indicator unaltered. A particular example is code that's called from a breakpoint. Having access to $ZR allows such code to record the value at its start and use it on exit to re-establish the same naked indicator.

    I think there's even an MDC proposal to standardize this. The foreword of X11.1-1995 acknowledges that that standard makes a reference to $REFERENCE in the definition of the function $QUERY.

    Any suggestions?

     
    • Vinaya Revannaswamy

      John, there is a way in GT.M to do obtain the last global reference. A command of the form:

      Set %ZR=$Name(^(n))

      where %ZR is an appropriately selected variable name for the application and n has any arbitrary value (say literal, 1), permits the naked reference to be later restored by a command such as:

      Set dummy=$Data(@%ZR))

      Please let us know if this scheme works for you. Please also note that we have included "$ZREFERENCE" in our list of features to be added to GT.M.

      Thanks,
      Vinaya
      Sanchez Computer Associates

       
    • John Murray

      John Murray - 2001-06-04

      Thanks Vinaya. I've now used that approach as a workaround for the lack of $ZREFERENCE. I wrapped the $NA() in an extrinsic function with error-trapping to handle the case where the naked is undefined (e.g. after referring to a global unsubscripted). The fact that no existing code can get at the *true* last global reference means it shouldn't matter that my code can't re-establish it. Provided I re-establish the same naked indicator, all should be well.

       
    • Ben Bishop

      Ben Bishop - 2001-07-11

      Note that you should probably implement $REFERENCE (rather than $ZREFERENCE) as it is in the 1995 standard.

       
      • John Murray

        John Murray - 2001-07-11

        Ben,

        I believe $REFERENCE *just* missed ANSI 1995. The Foreword to the standard notes that $REFERENCE is referred to in the definition of $QUERY, but that its own definition is not present. It goes on to state that $REFERENCE will occur in the next version of the standard.

        John

         

Log in to post a comment.