User bio
404 bio not found
Member since May 6, 2021
Replies:

It doesn't look like you are doing anything wrong but there must be something in the compiler that doesn't like you.

$Name hates class parameters but seems OK if you @ it

Parameter GlobalName = "^Glob(1)";

ClassMethod TestG() As %String [ ProcedureBlock = 0 ]
{
G=..#GlobalName
 // This only compiles when ProcedureBlock=0
$Name(G)
 
// This will not compile 
; s GN=$Name( ..#GlobalName )
// But this does and it works
 Q $Name( @..#GlobalName )
}

Hi, I wrote some code to access the ^ERROR global from a character based screen some years ago because the GUI was too slow and cumbersome. There's too much code to share on here but I can give you some direction on the global layout:

The location of ^ERRORS varies between current namespace and %SYS. I haven't looked in to why, it might be due to Caché version. This full program works from Caché 5 through to 2018.

 ClassMethod START(test = 0) As %String
{
NSP=$ZNSPACE,%ENSP=NSP ; Error global namespace could be "%SYS" or local namespace, haven't worked out how it changes
test NSP="%SYS",%ENSP=NSP
 ;
 ; work out where the ^ERRORS global is
$D(^ERRORS) {
  ; it's in the current namespace
%ENSP=NSP ; location of the error global
 }
 ElseIf $D(^["%SYS"]ERRORS) {
%ENSP="%SYS"
 }

 ; count the number of errors for this namespace by date. Date is $H
Date=""
 F  {
Date=$O(^[%ENSP]ERRORS(Date),-1) q:Date=""

Errors with a date are given a sequence number starting at 1 for the first error

 {
ERN=""
 F  {
ERN=$O(^[%ENSP]ERRORS(Date,ERN)) Q:ERN=""
  ; STACK 0 has got most of what we need to see right now
NSPACE=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$ZU( 5)"))
NSP=NSPACE,$I(COUNT) { 
   ; sort by time, latest to earliest
   ; stack 0 contains environment variables like $I, $J, etc. 
Time=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$H"))
Username=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$USERNAME"))
ZE=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$ZE"))

Further stack levels contain variables (including arrays and objects) and other stack information

 changePoint=$G(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"L"))
 var=$o(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var),1,value) q:var=""
 $D(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var))#2 {
ZR=$ZR
$p(value,"0 ",2)'="",..ListValid($p(value,"0 ",2)) {
  ; looks like a status code
   //" "_var_" = (status code - fail...)")
 }
 else {
  // (" "_var_" = "_value)
 }
value["<OBJECT REFERENCE>[" {
..ShowObject(ScreenObj3,ZR,.i,0)
  }
 }
 // Variables that are arrays
$D(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"N"))>1{
subs=""
j=1:1 {
subs=$O(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"N",subs),1,value)
   q:subs=""
   //(" "_var_"("_subs_") = "_value))

Objects are stored thus

 ClassMethod ShowObject(ScreenObj3 As ZSS.Screen, ZRef, ByRef i, expand = 1)
{
Date=$QS(ZRef,1)
ERN=$QS(ZRef,2)
Stack=$QS(ZRef,4)
var=$QS(ZRef,6)
value=@ZRef
 ; should be immediately followed by "OREF",1)=no of lines
 ; and "OREF",1,0)=something I don't know - could be a character count
 ; then loads of rows where each line is terminated by $C(13,10)
 ; re-add with expand/collapse marker
sign=$s(expand:" - ",1:" + ")
 //$LB(sign_var_" = "_value),$LB("OBJECT",ZRef))
expand {
row=""
line=1:1:$G(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"OREF",1)) {
row=row_$G(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"OREF",1,line))
$E(row,$l(row)-1,9999)=$c(13,10) {
   //$LB(" "_$e(row,0,$l(row)-2)))
row=""
   }
  }
 }

Once you've understood the global layout it wouldn't take a lot to kill off dates that you are not interested in any longer. I haven't needed to.

You are using GOTO after an error in programmer mode while debugging. After an error that stops execution the GOTO will just go to the next command. I haven't re-created what you did. My guess is that the existing value of $TEST is 1 (true) and is unaltered by the IF command that failed which means that the interpreter is happy that the next command is SET command. Ensure you define variable x with something sensible and/or write some code to check its value before using it. Alternatively, nest the whole thing in a TRY:CATCH construct to deal with the error.

Certifications & Credly badges:
Stuart has no Certifications & Credly badges yet.
Global Masters badges:
Stuart has no Global Masters badges yet.
Followers:
Stuart has no followers yet.
Following:
Stuart has not followed anybody yet.