go to post Stuart Strickland · Mar 19 I remember working on a system like that written in something called MaxiMumps. When doing their equivalent of $Order the second time you found null was the end of the subscript range. They also had an post-conditional character ";" which behaved like "if not". These two lines were effectively the same. S:A'=B C=D S;A=B C=D ...to save a character!
go to post Stuart Strickland · Feb 19 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 · Jan 3 I had to do something like this a few years ago to add a digital signature to a message in XML format. If I remember correctly you have to get your object into a %XML.Document which works in conjunction with %XML.Node. %XML.Node is used to traverse the %XML.Document to get to the section you want in canonical form. Then you pass the Node to ##class(%XML.Writer).Canonicalize(Node) to get the XML as a string which is then passed to the encryption function you use to get your digest/signature. You can pass the whole document or just a subsection to the canonicalize function. I can't say if it's the only or best way to do it but it was sufficiently quick enough to handle thousands of messages per minute.
go to post Stuart Strickland · Dec 14, 2022 Discourage the use of hard coded breaks in the first place! There are alternatives. Use ZBREAK Tag+OffSet^Routine to set a break point just for the current process Use the debugger in Cache´ Studio (under the Debug menu and attach to a process) George James has a decent debugger in Serenjii Put something in your processes to remove hard coded break points when you promote code through the development cycle (you can automate this if you try)
go to post Stuart Strickland · Nov 24, 2022 I've seen some places where the ^ROUTINE global is fully or partially deleted after compilation. I suspect that the same would work for ^rMAC or ^oddDEF - you'd have to test it. One company that I'm aware of encrypts the ^ROUTINE global after compilation which has the added "benefit" of making it extra difficult to debug errors! If you really want to hide your code you could compile the code on an identical system and then just deploy the object code.
go to post Stuart Strickland · Nov 11, 2022 I had the same thoughts but decided to make assumptions that allowed me to code using the least characters. If you cater for the tricky stuff you'd probably have to double the length of your code.
go to post Stuart Strickland · Nov 11, 2022 Shaved off another character ClassMethod Order(a As %String) As %String{1 s s=$p(a," ",$i(i)),n=$zstrip(s,"*a"),$p(z," ",n)=$tr(s,n) G 1:n Q $g(z)}
go to post Stuart Strickland · Nov 11, 2022 Make that 77 with this: ClassMethod Order(a As %String) As %String{ f{s s=$p(a," ",$i(i)),n=$zstrip(s,"*a"),$p(z," ",n)=$tr(s,n) ret:'n $g(z)}}
go to post Stuart Strickland · Nov 11, 2022 Nice generation of a pandigital number with 1e20/17. Can save a character with $zpi_0 ClassMethod Order(a As %String) As %String{ s r=a f i=1:1:5e5{s s=$p(a," ",i),w=$tr(s,$zpi_0),$p(r," ",$tr(s,w))=w} q r} This was mine also at 78: ClassMethod Order(a As %String) As %String{ f i=1:1 s s=$p(a," ",i),n=$zstrip(s,"*a"),$p(z," ",n)=$tr(s,n) ret:'n $g(z)}
go to post Stuart Strickland · Sep 1, 2022 And if you find the job is starting (from evidence provided by $T and $ZCHILD) then ensure you have an error trap in your class to catch why it's falling over. At the very least make it Set ^tempGlo($H)=$ZE or DO ^%ET when it encounters an error. If you can't edit the class for any reason then JOB a routine that you can edit and make that call your class after setting up an error trap.