go to post Vitaliy Serdtsev · Jan 2 By the way, what do you think this statement does? Note the %OpenId(20) at the end instead of %New(). #dim a,b,c As Sample.Person = ##class(Sample.Person).%OpenId(20)Confusing. How about this statement? #dim a,b,c As Sample.Company = ##class(Sample.Person).%New()Do you get 3 companies or 3 persons? Does it try to "cast" persons as companies? Do you get an error at compile time or run time? Would it work if Sample.Company extends Sample.Person? More confusion... There is no confusion. Here's another example where the class may not even exist and yet the code compiles without errors and according to the documentation. test.MAC #dim a,b,c As %Boolean = ##class(bla.bla).%OpenId(20) #dim a,b,c As bla.bla.bla123 = ##class(bla.bla).%OpenId(20)--> test.INT Set (a,b,c)=##class(bla.bla).%OpenId(20) Set a=##class(bla.bla).%OpenId(20),b=##class(bla.bla).%OpenId(20),c=##class(bla.bla).%OpenId(20)The only thing is that in this case Studio Assist will not work.
go to post Vitaliy Serdtsev · Jan 2 A good thing to know is, that there isn't actually a thing as 'during compile time' in ObjectScript. Do you think that the documentation contains an error? ##function Evaluates an ObjectScript function at compile time. #execute Executes a line of ObjectScript at compile time. ##expression Evaluates an ObjectScript expression at compile time.
go to post Vitaliy Serdtsev · Dec 29, 2025 There are nuances ;) According to the documentation, the following two lines will give different results at the runtime: #dim a,b,c = ##class(Sample.Person).%New() ; all the variables are assigned the same initial value #dim a,b,c As Sample.Person = ##class(Sample.Person).%New() ; each variable is assigned a separate OREF
go to post Vitaliy Serdtsev · Dec 22, 2025 IRIS 2025.3.CE ClassMethod test() [ Language = python ] { import iris ns = iris.system.Process.NameSpace() try: iris.system.Process.SetNamespace('%SYS') passenger = iris.SYS.Stats.Dashboard.Sample() print(passenger.GloRefsPerSec) finally: iris.system.Process.SetNamespace(ns) }PS: Do I need a separate python iris connection for each Namespace?
go to post Vitaliy Serdtsev · Dec 18, 2025 For each alphabetic character, determine its zero-based index in the lowercase alphabet (a-z). Preserve non-alphabetic characters unchanged. For clarify: does alphabetical characters include only the English letters a-z, A-Z, or all Unicode characters including "ªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéyêëìíîïðñtóôõöøùúûüýþÿ" ? What should be the correct result for the string "Hello World µÝ Привет Мир!" ?
go to post Vitaliy Serdtsev · Dec 17, 2025 Your task is to implement this encryption efficiently What does "efficiently" mean? The condition of the Code Golf competition has always been to write the shortest code, not the fastest (see Code Golf Index)
go to post Vitaliy Serdtsev · Dec 17, 2025 My current code size is 74 (where alphabetical characters only a-z,A-Z). size = 74 ClassMethod Encode(m) As %String { f j=65,97{f i=0:1:25 s m=$tr(m,$c(j+i),i#2)} q $re($e(m,1,*-1))_$e(m,*) } "Hello World µÝ Привет Мир!" -> "риМ тевирП Ýµ 11100 01101!" PS: why is the correct result in the testNumbers method 321 and not 213?
go to post Vitaliy Serdtsev · Dec 15, 2025 Caché/IRIS already has ready-made macros: $$$FormatText(), $$$FormatTextHTML(), $$$FormatTextJS() , which may be useful to you and which use #def1arg.
go to post Vitaliy Serdtsev · Dec 8, 2025 Wow! By the way, if you remove the second brackets, the query works: SELECT 1 WHERE ('') = '_㉸^'It requires Java 17, and InterSystems IRIS Enterprise (it uses many connections). Do I understand correctly that with the built-in Community Edition license, the SQLancer tool cannot be fully used?
go to post Vitaliy Serdtsev · Dec 8, 2025 One of the options for Caché 2018.1: set xmlStream=##class(%Stream.FileBinary).%New() set xmlStream.Filename="C:\test_from.xml" set jsonStream=##class(%Stream.FileBinary).%New() set jsonStream.Filename="C:\test_to.json" #dim d As %Document.Object = ##class(%Document.Object).XML(xmlStream) do d.%ToJSONStream(.jsonStream) do jsonStream.%Save()
go to post Vitaliy Serdtsev · Dec 8, 2025 For i = 1:1:maxRow { Set cel = pySheet.cell(i,y) If cel."is_date" { Set val = cel.value.date().isoformat() ; ODBC Date Set MolDatum = $zdh(val,3) ; LOGICAL Date Write $zd(MolDatum),! ; DISPLAY Date } }
go to post Vitaliy Serdtsev · Dec 1, 2025 Class dc.test [ Abstract ] { ClassMethod Test() { #dim ex As %Exception.AbstractException #dim xDataStream As %Stream.Object #dim mydoc As %XML.XPATH.Document try{ set xDataStream=##class(%Dictionary.CompiledXData).IDKEYOpen(..%ClassName(1),"ClinicalDocXData").Data $$$ThrowOnError(##class(%XML.XPATH.Document).CreateFromStream(xDataStream, .mydoc,,,,,"s urn:hl7-org:v3")) $$$ThrowOnError(mydoc.EvaluateExpression("//s:entry/s:Id", "text()", .tRes)) for i =1:1:tRes.Count() { write tRes.GetAt(i).Value,! } }catch(ex) { write "Error ", ex.DisplayString(),! } } XData ClinicalDocXData { <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <MainDocument xmlns="urn:hl7-org:v3"> <realmCode code="IT"/> <title>kjbkjkjbkjb</title> <effectiveTime value="20090905150716"/> <versionNumber value="1"/> <component> <body>mhvjhjkvhj</body> <component> <section>content</section> <ID>5</ID> <title>Certificato</title> <text/> <entry> <Id>5</Id> </entry> <entry> <Id>6</Id> </entry> </component> </component> </MainDocument> } }Result: USER>do ##class(dc.test).Test() 5 6
go to post Vitaliy Serdtsev · Nov 27, 2025 TEST.TEST.cls Class TEST.TEST Extends %Persistent { Property userActionone As %Boolean [ SqlColumnNumber = 2 ]; Property userActiontwo As %Boolean [ SqlColumnNumber = 3 ]; Property userActionthree As %Boolean [ SqlColumnNumber = 4 ]; Property userActionfour As %Boolean [ SqlColumnNumber = 5 ]; Property userActionfive As %Boolean [ SqlColumnNumber = 6 ]; Property userActionsix As %Boolean [ SqlColumnNumber = 7 ]; Property userActionseven As %Boolean [ SqlColumnNumber = 8 ]; Property userActioneigth As %Boolean [ SqlColumnNumber = 9 ]; Property userActionnine As %Boolean [ SqlColumnNumber = 10 ]; Property userActionten As %Boolean [ SqlColumnNumber = 11 ]; Property userActioneleven As %Boolean [ SqlColumnNumber = 12 ]; Property userActiontwelve As %Boolean [ SqlColumnNumber = 13 ]; Property userActionthirteen As %Boolean [ SqlColumnNumber = 14 ]; Property userActionfourteen As %Boolean [ SqlColumnNumber = 15 ]; ClassMethod Fill() { &sql(truncate table TEST.TEST) &sql(insert into TEST.TEST (userActionone, userActiontwo, userActionthree, userActionfour, userActionfive, userActionsix, userActionseven, userActioneigth, userActionnine, userActionten, userActioneleven, userActiontwelve, userActionthirteen, userActionfourteen) select 0,0,0,0,0,0,0,0,0,0,0,0,0,0 union all select 1,0,0,0,0,0,0,0,0,0,0,0,0,0 union all select 0,1,0,0,0,0,0,0,0,0,0,0,0,0 union all select 0,0,1,0,0,0,0,0,0,0,0,0,0,0 union all select 0,0,0,1,0,0,0,0,0,0,0,0,0,0 union all select 0,0,0,0,1,0,0,0,0,0,0,0,0,0 union all select 0,0,0,0,0,1,0,0,0,0,0,0,0,0 union all select 0,0,0,0,0,0,1,0,0,0,0,0,0,0 union all select 0,0,0,0,0,0,0,1,0,0,0,0,0,0 union all select 0,0,0,0,0,0,0,0,1,0,0,0,0,0 union all select 0,0,0,0,0,0,0,0,0,1,0,0,0,0 union all select 0,0,0,0,0,0,0,0,0,0,1,0,0,0 union all select 0,0,0,0,0,0,0,0,0,0,0,1,0,0 union all select 0,0,0,0,0,0,0,0,0,0,0,0,1,0 union all select 0,0,0,0,0,0,0,0,0,0,0,0,0,1 ) } } That's what I get: PS: Have you tried rebuilding the cube?
go to post Vitaliy Serdtsev · Nov 27, 2025 As you can see, the author asked two questions: In some cases, it's necessary to manipulate data from one namespace to another. For example, a routine in the "N1" namespace needs data from the "N2" namespace. In the same context, how could I make a persistent class global for all namespaces? The only way I know is by putting it in %SYS. What would be the best practices for these use cases? I answered the second question, and the other participants answered the first.
go to post Vitaliy Serdtsev · Nov 27, 2025 Both. Just for understanding. Will the result change if the conditions are reversed? For example: $SELECT( %source.userActionfourteen=1:"User action fourteen", %source.userActionthirteen=1:"User action thirteen", %source.userActiontwelve=1:"User action twelve", %source.userActioneleven=1:"User action eleven", %source.userActionten=1:"User action ten", %source.userActionnine=1:"User action nine", %source.userActioneigth=1:"User action eigth", %source.userActionseven=1:"User action seven", %source.userActionsix=1:"User action six", %source.userActionfive=1:"User action five", %source.userActionfour=1:"User action four", %source.userActionthree=1:"User action three", %source.userActiontwo=1:"User action two", %source.userActionone=1:"User action one", 1:"Other")
go to post Vitaliy Serdtsev · Nov 26, 2025 I agree. $CASE(1, %source.userActionone:"User action one", %source.userActiontwo:"User action two", %source.userActionthree:"User action three", %source.userActionfour:"User action four", %source.userActionfive:"User action five", %source.userActionsix:"User action six", %source.userActionseven:"User action seven", %source.userActioneigth:"User action eigth", %source.userActionnine:"User action nine", %source.userActionten:"User action ten", %source.userActioneleven:"User action eleven", %source.userActiontwelve:"User action twelve", %source.userActionthirteen:"User action thirteen", %source.userActionfourteen:"User action fourteen", :"Other")But the result will still be only one value, even if all %source.userActionXXX=1.
go to post Vitaliy Serdtsev · Nov 26, 2025 What result should $select return if the conditions %source.userActionone=1 AND %source.userActiontwo=1 are true ?
go to post Vitaliy Serdtsev · Nov 25, 2025 Distributing Library Packages: Percent (%) classes vs %ALL namespace
go to post Vitaliy Serdtsev · Nov 25, 2025 &sql(DECLARE C2 CURSOR FOR SELECT name INTO :name FROM person where name = :namevar)See Host Variables