go to post Julius Kavay · Mar 1, 2019 The correct way is: ClassMethod ind() [ PublicList = (active,reactive) ] { new active,reactive kill info // the above command (kill info) is a kind of NOP (no-operation) // at the time of entry into a methode there are no variables, // except those in the public list (if defined) set active = 1 set reactive = 2 for i="active","reactive" { set info(i)= @i } zw info break } If you want to use name-indirection in a procedure block, then - variables, used by indirection, must be made public (via PublicList) - and, depending on the situation, should be saved with the NEW command
go to post Julius Kavay · Feb 21, 2019 Maybe you want something like this: set data1 = "%sqlcq.something.value.foo" set data2 = "sqlcq.something.value.bar" for x=data1, data2 { if x ? .1"%"1"sqlcq".e { write "OK" } else { write "NOT" } w ! } Your output should be: OK OK Regards
go to post Julius Kavay · Jan 17, 2019 What do you mean with "from Code I am getting"? From which Code? ["\"KY\",\"TN\",\"AL\",\"GA\""] seems to be the same as the terminal output, except the quote chars are escaped...
go to post Julius Kavay · Jan 17, 2019 "like a centipede with a wooden leg: 99 times tic and 1 toc the stream is then truncated and still requires extra coding" That's the whole point! If we turncate the stream to $$$MaxStringLength, no matter where (in a calculated property or in a GETter method), just to present this (string)value to a variable, a function or whatever, then we can instantly stick to a string. By the way, it's possible to store $$$MaxStringLength bytes in a local or global variable. Properties of classes are stored in globals as $listelements, so the maxlength for a single string property depends on things like count and types of other properties in the class and not least, does this class extends %Persistent or extends another class(es) which extends %Persistent - in this case we need some extra bytes for those (extended) class names too.
go to post Julius Kavay · Jan 17, 2019 Supposed, you have a magical datatype of %StringOrMaybeStream and your property would be something like this: Property TheText As %StringOrMaybeStream So the next question is, how would your application use this magical property? The very first question is, how would you put your data into this magical property? Give me some (hypothetical) examples of use and I will try to give you a solution, if there is any.
go to post Julius Kavay · Sep 27, 2018 HANG command exists. You can put between each command (if you have enought time ;-)) ) an hang command: while response.StringValue="Processing" { hang 5 // pause for 5 seconds // get new response } Regards and have a nice day Julius
go to post Julius Kavay · Sep 20, 2018 Hello Kevin, if I anderstand you correctly, several your Cache systems (development, life, ...) will store their files on a third server (possibly on a file server) and you want to put the files from each (source) Cache (instance) into a different (target) folder, where the folder name being the "name" of the source Cache system - am I correct? If yes, I think, your best choice ist: ...\hostNameOfCache\instanceNameofCache... or, as John Murray suggested ...\GUIDofCacheInstance... or just a fixed string like ...\kevinNotebook(development)... You can put (John's) GUID or my "fixed string" in a (possibly system) Global like ^%Zconfig("path")=... Why? Things like MAC- or IP-Addresses can change more often then you think. Especially IP-Addresses will change, hence are there DNS servers. On the other hand, it's uncommon to change host- or instance names (of Cache or of whatever installation). Your IP-Address preference has an other downside too. Many servers have more then one IP-Address (and if they do not have one today, maybe tomorrow!). If you persist to take the systems IP-Address, here is, what you wanted: set iplist = $system.INetInfo.GetListOfConfiguredInterfaces(0) for i = 1:1:$listlength(iplist) zw $list(iplist,i) Regards and have a nice day Julius
go to post Julius Kavay · Sep 14, 2018 You can do it either this way: set OrgTypeId = $piece(line, ",", 2) // assuming, item 2 is an OID of ZenCrm.OrgType if ##class(ZenCrm.OrgType).ExistsId(OrgTypeId) { set rec.OrgType = ##class(ZenCrm.OrgType).%OpenId(OrgTypeId,0) } or this way: do rec.OrgTypeSetObjectId($piece(line, ",", 2))
go to post Julius Kavay · Aug 7, 2018 You are comparing apples wih oranges!The line (your case 1):set dat=$lg(^TestD(id)) //dat=$lb("a","b","c","d","e")sets dat to the FIRST list item (if present, or to "", if the list item is NOT present) of ^TestD(id) but ONLY if ^TestD(id) is defined AND it is a Cache list.In elsecase, you will get an <UNDEF> if ^TestD(id) does not exists or an <LIST> error, if ^TestD(id) exists but the content is not a list!The line (your case 2): set dat=$g(^TEST2(id)) //dat = "a#b#c#d#e"sets dat to the content of ^TEST2(id) , if it exists or to "", if there is no ^TEST2(id)
go to post Julius Kavay · Aug 1, 2018 If you want to compare collections, then you have to know what do you compare.Let look on this examples:1) Hobbies old: music, sport new: sport, music One could say, there is no difference (if all hobbies are equally preferred) 2) Work instructions old: format_disk, create_backup new: create_backup, format_disk In this example, if the work is done in a wrong sequence, the data are lost.In other words, if you compare collections, you have to take in account theimportance or unimportance of sequencies, which means, the compare functionneeds a third input argumentcompare(old, new, relyOnSequence, ...)By the way, your test() method has his very special "point of view" of lists:set old1=$lb("blue","red","green"), new1=$lb("green","red","blue")set null=$lb("", "", "")do ##class(...).test(old, new, .add, .del) write add=nul, del=nul --> 11do ##class(...).test(old, old, .add, .del) write add=nul, del=nul --> 11do ##class(...).test(nul, nul, .add, .del) write add=nul, del=nul --> 11Is this an expected behavior?
go to post Julius Kavay · Jul 5, 2018 On-the-fly and untested:set del=<your_csv_delimiter> // <;>, <tab>, <whatever...> while'stream.AtEnd { set line=stream.ReadLine() write line,! // this is csv set json=[] for i=1:1:$l(line,del) do json.%Push($p(line,del,i)) write json.%ToJSON(),! // or whatever other action you need...}HTHJulius
go to post Julius Kavay · Jan 7, 2018 The short answer ist:a) look for Mnemonics b) write /cup(line, column)c) use ?tabFor example: write #, "Hello", !, /cup(3,25),"Let's go....", !, "And now", ?20, "we are in column 20", !
go to post Julius Kavay · Oct 30, 2017 I think, your best bet is:write $zstrip($zstrip(text,"*c"),"<=>w")because you want to remoe ALL (i.e.: *) control chars but only SOME (i.e.: <=>) whitespaces.You could try something like:set chars=$c(0,1,2,3,....31, 32 /* blank */, ...<maybe other control chars, above 128>)write $tr(text,chars)hth
go to post Julius Kavay · Sep 5, 2017 Class your.class { Property Colors As list Of %String; ClassMethod toJson(list) As %String [ SqlProc ] { s json="" f i=1:1:$ll(list) { s:i>1 json=json_"," s item=$lg(list,i) if '$ld(list,i) { s json=json_"null" } elseif item="" { s json=json_"""""" } elseif $lv(item) { s json=json_..toJson(item) } elseif $num(item,".")=item { s json=json_$fn(item,"N") } else { f c="\","/","""",$c(8),$c(9),$c(10),$c(12),$c(13) s item=$replace(item,c,"\"_$tr(c,$c(8,9,10,12,13),"btnfr")) f q:'$locate(item,"[:cntrl:]",0,j,v) s $e(item,j-1)="\u"_$e($zh($a(v)+65536),2,5) s json=json_""""_item_"""" } } q "["_json_"]" } } select your.class_toJson(Colors) from your.class gives you the expected result . If you prefer a direct use of globals, then use write ##class(your.class).toJson($lg(^your.global(theOID),theSlotNumber))
go to post Julius Kavay · Aug 28, 2017 Cache dies not like an object property as a left side argument,but you can solve the problem much simpler:set context.NewID=$tr($j(context.PatientID,10)," ",0) By the way, if your solution would work, the result would be longer then 10 charsfor example, if context.PatientID=123 then youwould get: "000000123000"instead of: "0000000123"Regards,Julius
go to post Julius Kavay · Aug 28, 2017 my quick test says there are two chars, CR and LF, on an AIX and on Ubuntu USER>s str=##class(%GlobalCharacterStream).%New() USER>d str.WriteLine("Test") USER>d str.Rewind() USER>zzdump str.Read(100) 0000: 54 65 73 74 0D 0A Test.. USER> USER>w $zv Cache for UNIX (IBM AIX for System Power System-64) 2017.1 (Build 792U) Mon Mar 20 2017 19:19:37 EDT USER> ----------------- USER>s str=##class(%GlobalCharacterStream).%New() USER>d str.WriteLine("Test") USER>d str.Rewind() USER>zzdump str.Read(100) 0000: 54 65 73 74 0D 0A Test.. USER> USER>w $zv Cache for UNIX (Ubuntu Server LTS for x86-64) 2017.1 (Build 792U) Mon Mar 20 2017 19:22:31 EDT USER> Maybe, your problem has nothing to do with Cache? Regards, Julius