go to post Stuart Strickland · Jun 5 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 ] { s G=..#GlobalName // This only compiles when ProcedureBlock=0 q $Name(G) // This will not compile ; s GN=$Name( ..#GlobalName ) // But this does and it works Q $Name( @..#GlobalName ) }
go to post Stuart Strickland · Jun 3 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 { S NSP=$ZNSPACE,%ENSP=NSP ; Error global namespace could be "%SYS" or local namespace, haven't worked out how it changes I test S NSP="%SYS",%ENSP=NSP ; ; work out where the ^ERRORS global is i $D(^ERRORS) { ; it's in the current namespace S %ENSP=NSP ; location of the error global } ElseIf $D(^["%SYS"]ERRORS) { S %ENSP="%SYS" } ; count the number of errors for this namespace by date. Date is $H S Date="" F { S Date=$O(^[%ENSP]ERRORS(Date),-1) q:Date="" Errors with a date are given a sequence number starting at 1 for the first error { S ERN="" F { S ERN=$O(^[%ENSP]ERRORS(Date,ERN)) Q:ERN="" ; STACK 0 has got most of what we need to see right now S NSPACE=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$ZU( 5)")) I NSP=NSPACE,$I(COUNT) { ; sort by time, latest to earliest ; stack 0 contains environment variables like $I, $J, etc. S Time=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$H")) S Username=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$USERNAME")) S ZE=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$ZE")) Further stack levels contain variables (including arrays and objects) and other stack information S changePoint=$G(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"L")) s var=$o(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var),1,value) q:var="" i $D(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var))#2 { s ZR=$ZR i $p(value,"0 ",2)'="",..ListValid($p(value,"0 ",2)) { ; looks like a status code //" "_var_" = (status code - fail...)") } else { // (" "_var_" = "_value) } i value["<OBJECT REFERENCE>[" { d ..ShowObject(ScreenObj3,ZR,.i,0) } } // Variables that are arrays i $D(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"N"))>1{ s subs="" f j=1:1 { s 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) { S Date=$QS(ZRef,1) S ERN=$QS(ZRef,2) S Stack=$QS(ZRef,4) S var=$QS(ZRef,6) S 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 s sign=$s(expand:" - ",1:" + ") //$LB(sign_var_" = "_value),$LB("OBJECT",ZRef)) i expand { s row="" f line=1:1:$G(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"OREF",1)) { s row=row_$G(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"OREF",1,line)) i $E(row,$l(row)-1,9999)=$c(13,10) { //$LB(" "_$e(row,0,$l(row)-2))) s 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.
go to post Stuart Strickland · Apr 22, 2024 USER>w $tr("CcYyMmDd","Dd/Mm/CcYy","25/03/1988") 19880325
go to post Stuart Strickland · Feb 19, 2023 Hi Mark, When looping through numerics, unless you intervene, it will loop through every number in magnitude order until you reach the end. So, if you start at 8009 and 8010 exists then it will find it. And 8009 is not next to 800900001 by a long way. When looping through strings, it's going to go through them like a human would when going through a dictionary. All words with the same prefix are next to each other. So you can easily stop your loop immediately when you find a word that doesn't match. This code will probably do what you want, athough I haven't tested it: Noddy ;; Find all subscripts with numeric prefix using minimum $ORDER ;Find(Prefix=8009,MaxSubscriptlength=12) I Prefix=+Prefix { // Must be numeric S MatchLength=$l(Prefix) F I=MatchLength:1:MaxSubscriptLength { // try starting from every number beginning with // 8009, thru 80090, 800900, up to say 800900000000 // or whatever the maximum subscript length is S Start=Prefix_$E("000000000000",0,I-MatchLength) F { // see if we found one, even at the start of the loop I $D(^REXREF3(1,Start)) { // but it must have our prefix // this test can end the loop! Q:$E(Start,1,MatchLength)'=Prefix // but only looking for numerics in this loop // don't want to find again later Q:Start'=+Start // Now do whatever it is you want to do with it.. // <REMOVE MINE AND INSERT YOUR CODE HERE> W !,Start } S Start=$O(^REXREF3(1,Start)) Q:Start="" } } } // Now look for strings with that prefix // all strings starting with 8009 will immediately follow "8009 " // so start there, there won't be an numeric subscripts following a string S Start=Prefix S MatchLength=$l(Prefix) I Prefix=+Prefix S Start=Start_" " F { // see if we found one, even at the start of the loop I $D(^REXREF3(1,Start)) { // but it must have our prefix // this test can end the loop! Q:$E(Start,1,MatchLength)'=Prefix // Now do whatever it is you want to do with it.. // <REMOVE MINE AND INSERT YOUR CODE HERE> W !,Start } S Start=$O(^REXREF3(1,Start)) Q:Start="" } q
go to post Stuart Strickland · Sep 9, 2021 or include S X=$ZU(123,0,1,1) in your system startup routine so that the only date that ever shows up with a 2 digit year is 1st Jan 1841 Check out the old %DATE utility
go to post Stuart Strickland · Feb 24, 2020 I had similar problems with the digital signature classes provided with Caché solved by extending the classes and adding the missing properties. Once extended you could add and InclusiveNamespace property and populate it with anything you like. You may find that you have to extend the entire digital signature package or even copy the package to a new one so that you can add what you want.