go to post Julius Kavay · May 26, 2022 The standard ANSI escape sequenc should be: write $c(27)_"[42m"_"Your green backround"_$c(27)_"[m"_" and a normal dot." write $c(27)_"[32m"_"Your green text"_$c(27)_"[m"_" and a normal dot."
go to post Julius Kavay · May 25, 2022 Bye the way, non of Cache/IRIS has an $ZU command but all versions have a bunch of $ZU() functions. So what do you want to do with them?
go to post Julius Kavay · May 24, 2022 To get all the jobGUIDs you need two loops: f i=1:1:list1.Size f j=1:1:list1.GetAt(i).sensors.Size w list1.GetAt(i).sensors.GetAt(j).jobGUID,! 0b955ee7-9a54-4b13-9af1-7019721faeab 8f9e85ab-31e7-4835-8969-6d72d142a2f1 68cea9d3-54cd-43f2-ae37-aaf47ed43e6b 7602764e-8951-451f-9653-ceb84834a1a6 88d2e472-a1e4-40b3-a108-f2d32a2023e5 116f2ac6-da5f-46da-a7c7-92d9eaf98c89 a878e527-f519-4aaa-bf5d-0d65f72de119 be570b14-0555-4b86-ab9f-e37c40c79216 3a13e243-d6ed-4788-98b2-52e9213bee00 54969869-c4f6-43f6-a74a-2a67f9a73fc5 700af7d3-77b3-4a84-ba11-ea49602d6558 18dc3370-c291-468b-af1f-0361d95bb02c 35d0d2e7-1199-4c18-8941-4fff6dbdba1f 8044560c-94d2-4da7-87f5-07328d9e62c1 b636a2f5-d35f-4c82-9646-e09572336e23 9c9a4bf4-e8af-4b8d-9de2-a99cdff150ed a576d235-6eb6-4312-a1ff-7b1f767b88ce 654cf21e-daad-4a11-b676-86a7bc8a3360 2be4efc8-6616-4bff-87ba-30fe388a1b34 a5374d6c-311c-44d0-8d06-3a31f33dd3a8 955529c5-36be-4f3e-b768-0e3b377804a7 60a7cdb0-499e-4d02-b4d3-06ee58e40481 e84eda78-1491-49af-9e34-d647e817a251 9bcd5fe6-6f05-4482-ad78-612f35c60b41
go to post Julius Kavay · May 24, 2022 read json <now, Cntrl-V here the above string, press enter>, then w ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(json,,.list1) --> 1 w list1 --> 42@%Library.ListOfObjects w list1.GetAt(1).sensors.GetAt(1).jobGUID --> 0b955ee7-9a54-4b13-9af1-7019721faeab where is the problem?
go to post Julius Kavay · May 20, 2022 Try this one. The idea is, find the state (including the separators), everything before is the city and everything after is the zip code. Then we remove the separator chars (whitespaces, commas and dots). ClassMethod Disjoin(data, cty, sta, zip) { i $locate(data,"(\s|,|\.)[A-Za-z]{2}(\s|,|\.)",3,,sta) { s $lb(cty,zip)=$lfs(data,sta), sta=$$s(sta), cty=$$s(cty), zip=$$s(zip) } else { s (cty,sta,zip)="" } q sta]"" s(x) q $zstrip(x,"<>w",",.") } Some examples i ##class(DC.Test).Disjoin("CANTON,TX.,75103",.c,.s,.z) w c,", ",s,", ",z --> CANTON, TX, 75103 i ##class(DC.Test).Disjoin("MILFORD, OH 45150",.c,.s,.z) w c,", ",s,", ",z --> MILFORD, OH, 45150 i ##class(DC.Test).Disjoin("MILFORD OH 45150",.c,.s,.z) w c,", ",s,", ",z --> MILFORD, OH, 45150 i ##class(DC.Test).Disjoin("KANSAS CITY, MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> KANSAS CITY, MO, 12345 i ##class(DC.Test).Disjoin("KANSAS CITY MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> KANSAS CITY, MO, 12345 i ##class(DC.Test).Disjoin("ST. LOUIS MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> ST. LOUIS, MO, 12345 i ##class(DC.Test).Disjoin(" ST. LOUIS MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> ST. LOUIS, MO, 12345 OK, something like this gives a wrong result... i ##class(DC.Test).Disjoin(" ST. LOUIS MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> , ST, LOUIS MO, 12345
go to post Julius Kavay · May 16, 2022 Class DC.Test Extends %RegisteredObject { /// Return TRUE if val contains an string ClassMethod IsString(val) As %Boolean { q $a($lb(val),2)<3 } /// Return TRUE if val contains a number (int, real or double) ClassMethod IsNumber(val) As %Boolean { q $a($lb(val),2)>3 } } w ##class(DC.Test).IsString("abc") //--> 1w ##class(DC.Test).IsString("123") //--> 1w ##class(DC.Test).IsString(123) //--> 0w ##class(DC.Test).IsNumber(123) //--> 1w ##class(DC.Test).IsNumber("abc") //--> 0w ##class(DC.Test).IsNumber("123") //--> 0w ##class(DC.Test).IsNumber(123_345) //--> 0w ##class(DC.Test).IsNumber(123+345) //--> 1w ##class(DC.Test).IsString(123_456) //--> 1w ##class(DC.Test).IsString(123+456) //--> 0 s x=123, y="123"w ##class(DC.Test).IsString(x) //--> 0w ##class(DC.Test).IsString(y) //--> 1
go to post Julius Kavay · May 8, 2022 The input variable pInput is an object(reference). You can't save OREFs in a global! Think about OREFs as memory location (or, if you "speak" C, as a pointer). Trying to save it in a global is the same as saving a C pointer into a file for a later use... Won't work either
go to post Julius Kavay · Apr 29, 2022 People call it the reverse mode of $translate(). I saw this kind of usage of $tr() some 20 years ago. If I recall it right, it was mentioned in an article on usenet: comp.lang.mumps.
go to post Julius Kavay · Mar 17, 2022 I'm quite shure, the above code won't work as expected, or with the words of Joseph Weizenbaum: “A computer will do what you tell it to do, but that may be much different from what you had in mind.” The content of your myf variable is always 0 (the result of comparing nullstring with a filename), the size of tmpFile stream is also 0 (you never write into the stream). Sometimes it's faster to write a "oneliner" to solve a simple problem then searching and downloading a solution from openexchange or from whereever... That's the beauty of the ObjectScript. And if you think, the oneliner is worth to be reused, then make it to a method, add some small adjustments for a general usability... The oneliner s str="",tmp=##class(%File).TempFilename("txt") o tmp:"NWRU":0 i $t { u tmp zw ^||fruit s s=$zpos r:'$zseek(0) str#s c tmp:"D" } The more general version ClassMethod ToString(ref,max=32000) { s tmp=##class(%File).TempFilename("txt") o tmp:"NWRU":0 q:'$t "" u tmp zw @ref s siz=$zpos r:'$zseek(0) str#$s(siz>max:max,1:siz) c tmp:"D" q str } Use it as write ##(your.class).ToString($na(^||fruit))
go to post Julius Kavay · Jan 31, 2022 First, disable the start of %ZSTART: ManagementPortal-->SystemAdmin-->Configuration-->AdditionalSettings-->Startup: here, set SystemStart to false. Now, you can (Re)Start the system and check the %ZSTART routine. <DIRECTORY> means, trying to access a nonexistent database directory. After solving the problem, set SystemStart to true.
go to post Julius Kavay · Jan 31, 2022 The simplest way is to create a classmethod, which returns the desired name: Class DC.Evgenys.Data Extends %Persistent { /// which: 0=Fullname, 1=Schemaname, 2=Tablename ClassMethod TableName(which = 0) [ CodeMode = objectgenerator ] { set sch=%compiledclass.SqlSchemaName, tab=%compiledclass.SqlTableName do %code.WriteLine($c(9)_"quit $p("""_sch_"."_tab_","_sch_","_tab_""","","",which+1)") quit $$$OK } } So you can do something like this: for i=0:1:2 write ##class(DC.Evgenys.Data).TableName(i),! DC_Evgenys.Data DC_Evgenys Data
go to post Julius Kavay · Jan 28, 2022 You forgot to take into account the $system.SQL.* variants . They make much more fun, especially because you get time for a coffee break...
go to post Julius Kavay · Jan 28, 2022 Class My.Class { Property MyProperty As %String [ReadOnly]; Method %OnNew(init As %String) As %Status [ Private, ServerOnly = 1 ] { set i%MyProperty = init } } And use it as set obj = ##class(My.Class).%New("Some initial value") write obj.MyProperty --> Some initial value set obj.MyProperty --> <CANNOT SET THIS PROPERTY>
go to post Julius Kavay · Jan 28, 2022 A possible work-around could be the class below. In short, you work with your json property as intended, merely before saving the object, you save the json-property into a stream and after opening an instance, you restore the json-property from the the stream - that's all. The drawback, no SQL over the json property... Class DC.Dyn Extends %Persistent { Property json As %DynamicObject [ Transient ]; Property jstr As %GlobalCharacterStream [ Internal, Private ]; ClassMethod MyTest(kill = 0) { if kill do ..%KillExtent(1,1) set obj=..%New() set obj.json.short="A short test text" set obj.json.maxstr=$tr($j("",$$$MaxStringLength)," ","X") do obj.json.%Set("hugedata",..stream(obj),"stream") write "Status : ",obj.%Save(),! set id=obj.%Id() write "ID : ",id,! kill (id) set obj=..%OpenId(id) write "short : ",obj.json.short,! write "maxstr : ",$e(obj.json.maxstr,1,20),"... Size: ",$length(obj.json.maxstr),! set stream=obj.json.%Get("hugedata",,"stream") write "hugedata: ",stream.Read(20),"... Size: ",stream.Size,! } ClassMethod stream(obj) { set stream=##class(%Stream.TmpCharacter).%New() do stream.Write(obj.json.short) do stream.Write(obj.json.maxstr) do stream.Write(obj.json.maxstr) quit stream } Method %OnOpen() As %Status [ Private, ServerOnly = 1 ] { if ..jstr { do ..jstr.Rewind() set ..json=##class(%DynamicAbstractObject).%FromJSON(..jstr) } Quit $$$OK } Method %OnAddToSaveSet(depth As %Integer = 3, insert As %Integer = 0, callcount As %Integer = 0) As %Status [ Private, ServerOnly = 1 ] { do ..jstr.Clear(), ..json.%ToJSON(..jstr) Quit $$$OK } } Some testing... IDEV:USER>d ##class(DC.Dyn).MyTest(1) Status : 1 ID : 1 short : A short test text maxstr : XXXXXXXXXXXXXXXXXXXX... Size: 3641144 hugedata: A short test textXXX... Size: 7282305 If your code uses obj.%Reload() then %OnReload() and %OnOpen() should contain the same code.
go to post Julius Kavay · Jan 27, 2022 Your solution is just perfect. And fast. But yes, you can avoid string manipulations... This one, for example, uses math only, merely it's neither short nor looks elegant: set dt=$h write $zd(dt,8)*100+($p(dt,",",2)\3600)*100+($p(dt,",",2)#3600\60)*100+($p(dt,",",2)#60) but gives the same result as your short and nice solution... set dt=$h write $zd(dt,8)*100+($p(dt,",",2)\3600)*100+($p(dt,",",2)#3600\60)*100+($p(dt,",",2)#60),!,$tr($zdt(dt,8)," :") On the other hand, you can install new brakes on your car, as suggested by others... ;-)) Just compare those codes with yours: set h=$h, t=$zh for i=1:1:1E6 { set x=$tr($system.SQL.TOCHAR($h,"YYYY^MM^DD^HH24^MI^SS"),"^") } write $zh-t,! set h=$h, t=$zh for i=1:1:1E6 { set x=$tr($zdt(h,8)," :") } write $zh-t,! The choice is yours...
go to post Julius Kavay · Dec 20, 2021 A simple write ##class(%SYS.Namespace).GetPackageDest(yourNsp, yourPackage) should do the trick The same goes for globals and routines write ##class(%SYS.Namespace).GetGlobalDest(yourNsp, yourPackage) write ##class(%SYS.Namespace).GetRoutineDest(yourNsp, yourPackage) if yourNsp is not provided, the current Nsp will be used
go to post Julius Kavay · Dec 4, 2021 Just to put things in right perspektive, those "one letter commands" and "a lot of them in the same line" were neither tempting nor addictive, they were simply necessity! At the time of the birth of MUMPS (the core of Cache/IRIS/etc.), more then 50 years ago in the second half of 1960es, memory (which was a real core memory at the time) was rare and expensive and was measured in units of kilobytes! Just to contrast, today's server have the same amount of RAM, but in gigabytes, that's a factor of one million! As a consequence of memory shortage and because MUMPS of that time was interpreted (i.e. you loaded the sourcecode into memory), one had to utilize each and every possibility to save memory. One of those possibilities were the ability of the language to short each command to one letter and to put as many commads as possible into one line (thereby saving line-ending bytes). The tools (to save memory) of that (ancient) time were argumentless IFs and ELSES, short (variable-, global- and routine) names, commands with postcondition and sophisticated programming. Last but not least, if one aims to "modernize" thos old applications, should be keept in mind, especially, if one is not so familiar with the old fashioned style and methods, there will be many unexpected pitfalls. Sample1: on old printers, the line with "Total..." will be printed "bold-alike" write "last item",?15,$j($fn(val,",",2),10),! write ?15,"----------",! do do do . write $c(13),"Total",?15,$j($fn(sum,",",2),10) write !!!,"Due date for payment ....",! Sample2: converting from: ; normal flow do . ; nested . ; commands ; normal flow into: ; normal flow if 1 { ; nestd ; commands } ; normal flow will be in most cases OK, except, if the nested part uses the current value of $STACK:this is now one less then in case of argumentless DO!
go to post Julius Kavay · Nov 13, 2021 The reason is, the database encryption is not activated - see the last line in your screenshot. Go to MangementPortal, SystemAdministration --> Encryption. There you can create the encryption keys and activate the encryption.