go to post Stuart Strickland · Sep 12 Hi Robert, I had to write something similar myself about 20 years ago when we moved from DSM to Caché to deal with all those pesky &$ZLIB functions. On top of that there was the problem of variable names that exceeded 8 characters. DSM was quite happy to truncate a variable to 8 characters and work with it. For example, a variable named LONGVAR was the same variable as one named LONGVARIABLE just because the first 8 were the same. Under DSM if you SET one of them the other was also SET, but not under Caché. All of these had to be found and corrected.
go to post Stuart Strickland · Jun 25 Yes, and it will remove all those from the front and all those from the end, preserving those in the middle.
go to post Stuart Strickland · Jun 25 F Q:$c(10,13)'[$e(str)!'$L(str) s $e(str)="" // strip $c(10) and $c(13) from front F Q:$c(10,13)'[$e(str,*)!'$l(str) s $e(str,*)="" // strip $c(10) and $c(13) from end
go to post Stuart Strickland · May 26 //Untested, just to get started.. about 127 Class codeGolf.SmileyFace Extends %RegisteredObject{ ClassMethod Count(i As %String) As %Integer{ f p=1:1:$l(i){i $e(i,p,*)?1(1":",1";",1"8",1"B",1"=").1(1"-",1"^",1"c",1"o",1"~")1(1")",1"]",1"}",1"D",1">").e,$i(c)} q $g(c) } }
go to post Stuart Strickland · May 2 In the absence of an Intersystems' prescribed method I would set up a global variable with extra information on each namespace, e.g. ^%ZSYS("NAMESPACE","SYS")="IRIS" ^%ZSYS("NAMESPACE","LIVE")="CUSTOMER PRODUCTION" The global variable with % at the start means it can be seen from all namespaces. You can add whatever information you like to it like the difference between production and non-prod etc.
go to post Stuart Strickland · Mar 15 174 probably from an inaccurate count of the difference between some versions. You still have the r#2:3 problem W ##Class(CodeGolf.LengthOrder).Type("abc,de","de,abc") should be Unsorted
go to post Stuart Strickland · Mar 15 Size=177, problem fixed and another reduction found at the start of the $Select ClassMethod Type(a...) As %String{ f i=$i(r):1:$g(a){f j=1:1:$L(a(i),","){s L=$L($tr($p(a(i),",",j)," ")),r=$s(L=$g(c,L):r,r<3*L>c:2,r#2*c>L:3,1:4),c=L} k c} q $p("Constant1Increasing1Decreasing1Unsorted",1,r)}
go to post Stuart Strickland · Mar 15 Any of these that use r#2:3 give the wrong answer for W ##Class(CodeGolf.LengthOrder).Type("abc,de","de,abc")
go to post Stuart Strickland · Mar 14 Shaved down to 174. A dubious $Find-2 to get first string length. Changed a condition in the $Select from p<c&(r<3) to r<3*c>p ClassMethod Type(a...) As %String{ f j=$i(r):1:a{s w=$tr(a(j)," "),p=$f(w,",")-2 f i=2:1:$l(w,",") s c=$l($p(w,",",i)),r=$s(p=c:r,r<3*c>p:2,r#2:3,1:4),p=c} q $p("Constant7Increasing7Decreasing7Unsorted",7,r)}also fits in @Robert Barbiaux attempt ClassMethod Type(a...) As %String{ f i=$i(r):1:$g(a){f j=1:1:$l(a(i),","){s l=$l($tr($p(a(i),",",j)," ")),c=$g(c,l),r=$s(l=c:r,r<3*l>c:2,r#2:3,1:4),c=l} k c} q $p("Constant1Increasing1Decreasing1Unsorted",1,r)}
go to post Stuart Strickland · Mar 14 The for loop initialising r to 1 is top class thinking. You can still take 2 more characters off: ClassMethod Type(a...) As %String{ f j=$i(r):1:a{s w=$tr(a(j)," "),p=$f(w,",")-2 f i=2:1:$l(w,",") s c=$l($p(w,",",i)),r=$s(p=c:r,p<c&(r<3):2,r#2:3,1:4),p=c} q $p("Constant7Increasing7Decreasing7Unsorted",7,r)}
go to post Stuart Strickland · Mar 13 Yes this time, but unfortunately running tests agains ClassMethod Test1() and then posting ClassMethod Test() on here can make me look silly.
go to post Stuart Strickland · Mar 13 size=193 ClassMethod Type(a...) As %String{ s r=3 f i=1:1:a{s w=$tr(a(i)," "),b=$l($p(w,",")) f p=2:1:$l(w,",") s c=b,b=$l($p(w,",",p)),d=$s(c<b:1,c>b:2,1:3),r=$s(r=3:d,3_r[d:r,1:4)} q $p("Increasing1Decreasing1Constant1Unsorted",1,r)}
go to post Stuart Strickland · Mar 12 I'm afraid not. I didn't read the question properly but thankfully we have you who does a better job than test cases! Corrected it now.
go to post Stuart Strickland · Mar 12 ClassMethod Type(args...) As %String{ // no attempt made at miniturizing the code, 362 chars not including comments s res="Constant" f i=1:1 { q:'$d(args(i)) s w=$tr(args(i)," ") f p=2:1:$l(w,",") { s a=$l($p(w,",",p)),b=$l($p(w,",",p-1)) s d=$s(a>b:1,a<b:-1,1:0) i d>0 s res=$case(res,"Constant":"Increasing","Increasing":"Increasing",:"Unsorted") i d<0 s res=$case(res,"Constant":"Decreasing","Decreasing":"Decreasing",:"Unsorted") } } q res}
go to post Stuart Strickland · Nov 16, 2023 You need an interactive user's system to run this without any user interaction? If it doesn't matter who runs it and it doesn't take any serious resources and could run unnoticed then could you set a global that is checked by some code that is regularly run by a group of users? The first interactive process that finds the global could do your $ZF for you? Say SET ^GLOBAL("RUN NOTEPAD")=$H Then in the common piece of code L +^GLOBAL("RUN NOTEPAD"):0 I $T {S:$D(^GLOBAL("RUN NOTEPAD")) X=$ZF(-1,"C:\Windows\notepad.exe") K ^GLOBAL("RUN NOTEPAD") L -K ^GLOBAL("RUN NOTEPAD")} Otherwise I think you need to fix the destination program so it will run in the background.
go to post Stuart Strickland · Nov 10, 2023 Thanks Vitaliy! That is just what I was looking for! I suppose that underneath the code, deep down in Quote^%qcr, it may be doing the same as I'm doing, but it is unlikely to have any errors in it and it's not a wild assumption that it will do it in the most efficient way. Alas, the few version 5 sites will have to live with my slower code %SYS>w $zvCache for UNIX (IBM PowerPC/32-bit) 5.0.18 (Build 6103 + Adhoc 3626) Tue Mar 7 2006 11:55:33 EST%SYS>W $zcvt(##CLASS(%Library.Utility).FormatString($lb("abc","DEF","",,"tesT",$lb(0))),"u") W $ZCVT(##CLASS(%Library.Utility).FormatString($LB("abc","DEF","",,"tesT",$LB(0)^)),"u")<CLASS DOES NOT EXIST>%SYS>W $zcvt(##CLASS(%Utility).FormatString($lb("abc","DEF","",,"tesT",$lb(0))),"u") W $ZCVT(##CLASS(%Utility).FormatString($LB("abc","DEF","",,"tesT",$LB(0))),"u")^<CLASS DOES NOT EXIST>
go to post Stuart Strickland · Nov 9, 2023 Thank you Erin. That's a nice try but $c(1) isn't guaranteed in a $LIST s x=$lb(0) zzdump x
go to post Stuart Strickland · Nov 8, 2023 That's a really good idea. Doesn't quite get there because of nested lists. Here is a bit more visual info on the problem: >s x=$LB("test","for","searching unknown strings here is a very long piece with enough characters to get a lowercase alpha as a $list marker","items","in","lists",$lb("/subs","/values","nested list","did you see that ""w"" before the third piece?")) >f i=1:1:$l(x) s c=$e(x,i) w:c?1c "$c("_$a(c)_")" w:c'?1c c $c(6)$c(1)test$c(5)$c(1)forw$c(1)searching unknown strings here is a very long piece with enough characters to get a lowercase alpha as a $list marker$c(7)$c(1)items$c(4)$c(1)in$c(7)$c(1)listsM$c(1)$c(7)$c(1)/subs$c(9)$c(1)/values$c(13)$c(1)nested list.$c(1)did you see that "w" before the third piece? It's those potential lowercase list separators that are forcing me to go the long way round with stepping through each piece. $ListToString may help speed the code up especially as I'm not really expecting deep nesting of lists.