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.
go to post Stuart Strickland · Nov 8, 2023 Thanks Dmitry I want to find any string in another string that could be a plain string, a $LIST, or a series of nested $LIST to any depth - basically an unkown structure. The string I'm searching in can be any size and the pieces can be any size. And I wan't to do a case insensitive search through a large amount of data and I want instant results. And I want to know the character positions of what was found. And I want the results in a human readable format. And just to make it hard, it has to run on everything from Caché version 5 upwards which means $LISTNEXT, $LISTVALID are not always available.
go to post Stuart Strickland · Nov 8, 2023 That would be fine if I was looking for the full element value as my search string. I'm looking for any occurance, full or part, in a lot of data. From the documentation: $LISTFIND searches the specified list for the first instance of the requested value. A match must be exact and consist of the full element value. Letter comparisons are case-sensitive. Numbers are compared in canonical form. If an exact match is found, $LISTFIND returns the position of the matching element. If value is not found, $LISTFIND returns a 0. // Suppose the string I'm looking in is in S X=$LB("Stuart Strickland","Yaron Munz") // X could be anything // and I'm looking for "MUNZ" I $zcvt(X,"u")["MUNZ" Q 1 // I think this is quick but could cause a problem by converting lower case $LIST spacers to upper S sc=0 F i=1:1:$LL(X) S Y=$LG(X,i) I $zcvt(Y,"u")["MUNZ" s sc=1 // I think this is slow S sc=$LISTFIND(X,"MUNZ") // I know this will not work S sc=$LISTFIND($zcvt(X),"MUNZ") // I know this will not work and might even cause an error Q sc
go to post Stuart Strickland · Oct 23, 2023 132 ClassMethod Calendar(y As %Integer) As %String{q $p("Metal7Water7Wood7Fire7Earth",7,y#10\2+1)_" "_$p("Monkey7Rooster7Dog7Pig7Rat7Ox7Tiger7Rabbit7Dragon7Snake7Horse7Goat",7,y#12+1)}
go to post Stuart Strickland · Aug 3, 2023 Team effort. Credit where it is due, @Julius Kavay introduced the nested $TR, I changed his "" to a single character that didn't need a quote.
go to post Stuart Strickland · Aug 3, 2023 That article is an interesting read for anyone who has written code that goes directly to the generated INT code. I will need to re-think some of my older code that finds lines of code from $ZE and then displays and diagnoses the source of errors based on the variable names it finds there. I might also have to start using a mainstream debugger.
go to post Stuart Strickland · Aug 2, 2023 Ah yes, $Change can save a character on $Replace. And nested $TR saves on $zstrip. f{s z=x,x=$change($tr(x,$tr(x,"()")),"()",9) ret:x=z x=""}
go to post Stuart Strickland · Aug 2, 2023 //57? ClassMethod IsValid(s As %String) As %Boolean { q +$$zTestSearchString^%iFind.Utils.1($$$URLENCODE(s)) }
go to post Stuart Strickland · Aug 1, 2023 You are correct. implementation.size sees $c(13,10) as the end of line character. I counted manually and added 1, not 2.
go to post Stuart Strickland · Jul 28, 2023 61 bytes. Could an AI machine ever beat a human at code golf? Don't they just use brute force? ClassMethod IsValid(x){ f{s z=x,x=$replace($tr(x,$tr(x,"()")),"()",9) ret:x=z x=""}}
go to post Stuart Strickland · Jul 28, 2023 Class codeGolf.ParenthesisHell { ClassMethod IsValid(s As %String) As %Boolean { f{s t=s,s=$replace(s,"()","") ret:t=s s=""} }
go to post Stuart Strickland · Jul 14, 2023 I found a work around for it. Not perfect but it will do S RTN=$ZU(96,9) // or $SYSTEM.Process.CallingRoutine() which is identical in this situation I RTN="" F I=$ZU(41):-1:1 S RTN=$P($ZU(41,I),"^",3) I RTN'=$T(+0) Q:RTN'=""
go to post Stuart Strickland · Jul 13, 2023 It appears to only work intermittently from "D zzpp". If I ZLOAD another routine then go back and ZLOAD the first one, then it doesn't work. But if I issue an argumentless ZSAVE followed by "d zzpp" it works again.