Vitaliy Serdtsev · Jun 15, 2018 go to post

Add the RenderDirectlyOnTimeout property in the report:

Property RenderDirectlyOnTimeout As %ZEN.Datatype.boolean(ZENURL "$RENDERDIRECTLYONTIMEOUT") [ InitialExpression = {$$$NO} ];

Then you will get the following error:

ERROR #5001: Cannot contact server on port %1.
or
ERROR #5001: Received Control-C or there was a fatal error.
Vitaliy Serdtsev · Jun 14, 2018 go to post

Try so:

<FONT COLOR="#000080">Class dc.test Extends %ZEN.Component.page
</FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">XData </FONT><FONT COLOR="#000000">Contents [ </FONT><FONT COLOR="#000080">XMLNamespace </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"http://www.intersystems.com/zen" </FONT><FONT COLOR="#000000">] {   <</FONT><FONT COLOR="#000080">page </FONT><FONT COLOR="#800000">xmlns</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"http://www.intersystems.com/zen"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"btn1" </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Test Server"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"btn2" </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Test Client"</FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">page</FONT><FONT COLOR="#000000">> }

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">SrvTest() [ </FONT><FONT COLOR="#000080">ZenMethod </FONT><FONT COLOR="#000000">] {   </FONT><FONT COLOR="#800080">&js<</FONT><FONT COLOR="#000000">zenAlert(</FONT><FONT COLOR="#800000">'from Server'</FONT><FONT COLOR="#000000">);</FONT><FONT COLOR="#800080">> </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">test() [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   zenAlert(</FONT><FONT COLOR="#800000">'from Client'</FONT><FONT COLOR="#000000">); }

</FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">onloadHandler() [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   document.getElementById(</FONT><FONT COLOR="#800000">'btn1'</FONT><FONT COLOR="#000000">).addEventListener(</FONT><FONT COLOR="#800000">'click'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">new </FONT><FONT COLOR="#000000">Function(</FONT><FONT COLOR="#800000">'evt'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'return zenPage.SrvTest();'</FONT><FONT COLOR="#000000">),false);   document.getElementById(</FONT><FONT COLOR="#800000">'btn2'</FONT><FONT COLOR="#000000">).addEventListener(</FONT><FONT COLOR="#800000">'click'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">new </FONT><FONT COLOR="#000000">Function(</FONT><FONT COLOR="#800000">'evt'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'return zenPage.test();'</FONT><FONT COLOR="#000000">),false); } }</FONT>

Vitaliy Serdtsev · Jun 14, 2018 go to post

Suppose there is such a code:

int caseSwitch =1;
 
switch(caseSwitch){case1:
Console.WriteLine("Case 1");//a lot of codebreak;
 
case2:case8-9:
Console.WriteLine("Case 2 or 8 or 9");//a lot of codebreak;
 
case3:
Console.WriteLine("Case 3");//a lot of codebreak;
 
/...
a lot conditions
.../
 
default:
Console.WriteLine("Default case");//a lot of codebreak;}
In this case
  1. $select;if/elseif/else is not effective because for last conditions will have to iterate through all the previous ones
  2. $case is redundant: you will have to specify the same code multiple times for different values

For this particular case, I suggest using a transition table, for example:

<FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test(</FONT><FONT COLOR="#ff00ff">caseSwitch </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">3</FONT><FONT COLOR="#000000">) [ </FONT><FONT COLOR="#000080">ProcedureBlock </FONT><FONT COLOR="#000000">= 0 ]
{
  </FONT><FONT COLOR="#0000ff">s</FONT><FONT COLOR="#000000">:'</FONT><FONT COLOR="#0000ff">$d</FONT><FONT COLOR="#000000">(^||addr) ^||addr(1)=1,
                (^(2),^(8),^(9))=289,
                 ^(3)=3
  
  </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">@(</FONT><FONT COLOR="#008000">"case"</FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#0000ff">$g</FONT><FONT COLOR="#000000">(^||addr(</FONT><FONT COLOR="#800000">caseSwitch</FONT><FONT COLOR="#000000">),</FONT><FONT COLOR="#008000">"def"</FONT><FONT COLOR="#000000">))
  </FONT><FONT COLOR="#0000ff">q  

</FONT><FONT COLOR="#ff0000">case1   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Case 1"   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">case289   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Case 2 or 8 or 9"   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">case3   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Case 3"   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">casedef   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Default case"   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000000">}</FONT>

Of course, you can modify the example to call procedures, functions, class methods, etc.

Vitaliy Serdtsev · Jun 14, 2018 go to post

And if so?

Class dc.EmbedObj Extends %SerialObject
{

Property pOID As %ObjectIdentity Private ];

Property As %String;

Property As %String CalculatedSqlComputeCode = {{*}=##class(dc.EmbedObj).Calcb({pOID})}, SqlComputed ];

ClassMethod Calcb(pOIDAs %String
{
  r=""
  q:pOID="" r

  s $lb(id,cls)=$lfs(pOID,"@")

  p=$system.OBJ.OpenId(cls,id)
  q:'$IsObject(pr

  cls="dc.ContainerObj" {
    r="b"_p.Foobar
  }elseif cls="dc.blablablaContainerObj" {
    r="b"_p.qwe
  }
  r
}
}Class dc.ContainerObj Extends %Persistent
{

Property Foobar As %String;

Property InnerObj As dc.EmbedObj;

Trigger NewTrigger1 [ Event = INSERT, Foreach = row/object, Time = AFTER ]
{
  oid
  oid={%%ID}_"@"_{%%CLASSNAMEQ}
  &sql(update dc.ContainerObj set InnerObj_pOID=:oid where %ID=:{id})
}

/// d ##class(dc.ContainerObj).Test()
ClassMethod Test()
{
  ..%KillExtent()
  
  t=..%New()
  t.Foobar="foobar1"
  t.InnerObj.a="a1"
  t.%Save()

  &sql(insert into dc.ContainerObj(Foobar,InnerObj_avalues('foobar2','a2'))
  
  ##class(%SQL.Statement).%ExecDirect(,"select * from dc.ContainerObj").%Display()
}
}
Vitaliy Serdtsev · Jun 13, 2018 go to post

For serial class, I'm afraid that's not possible because of its nature. $this, $classname, etc. in the context of EmbedObj don't know anything about ContainerObj.

Use bidirectional Relationship.

Vitaliy Serdtsev · Jun 13, 2018 go to post

You can change the XSLFO Stylesheet dynamically or statically. See XSLFOSTYLESHEET

So, there is a class-report, for example MyApp.ReportDemo.

Series of steps:
  1. remove option XSLFOSTYLESHEET, if any, and recompile class
  2. generate XSLFO Stylesheet:
    SAMPLES>d $system.OBJ.DisplayError(##class(MyApp.ReportDemo).GenerateToFile($system.CSP.GetFileName($system.CSP.GetDefaultApp($zu(5))_"/MyApp.ReportDemo.xsl"),4))
  3. make changes to MyApp.ReportDemo.xsl
  4. add the parameter XSLFOSTYLESHEET and recompile the class again
    /// If defined, this provides a reference to the external
    /// stylesheet to use in generating the XSL-FO (PDF) report.
    /// If it is not provided, a stylesheet will be generated 
    /// from the ReportDisplay XData block.
    Parameter XSLFOSTYLESHEET As String = "MyApp.ReportDemo.xsl";

Now open the report in your browser/command line/etc. Profit!

Important: if you change something in ReportDisplay, you need to repeat the steps again.

Vitaliy Serdtsev · Jun 12, 2018 go to post

Page numbering in Roman Numerals

Need add the attribute format to the element <fo:page-sequence>, i.e.
<fo:page-sequence master-reference='blablabla' format ='I' .. >

Possible value format:

  • format="1" results in 1 2 3 . .
  • format="01" results in 01 02 03
  • format="a" results in a b c . .
  • format="A" results in A B C. .
  • format="i" results in i ii iii iv . .
  • format="I" results in I II III IV . .
  • more..

Example:

  1. Do all the steps according to Zen Report Tutorial
  2. Insert the page number into <pagefooter>
    <!-- Optional Pagefooter element. Does not apply in HTML output. -->
    <pagefooter>
    <item special="page-number"/>
    </pagefooter>
  3. Insert the following code into the class:
    ClassMethod ReplaceStream(
      ByRef stream As %Stream.TmpBinary,
      format) [ Private ]
    {
      tmp=##class(%Stream.TmpBinary).%New()
      while 'stream.AtEnd {
        tmp.Write($replace(stream.Read($$$MaxLocalLength),"<fo:page-sequence ",$$$FormatText("<fo:page-sequence format=%1 ",$$$quote(format))))
      }
      stream.CopyFrom(tmp)
    }

    <FONT COLOR="#000080">/// d ##class(MyApp.ReportDemo).Test() ClassMethod </FONT><FONT COLOR="#000000">Test(</FONT><FONT COLOR="#ff00ff">format </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"1"</FONT><FONT COLOR="#000000">) {   </FONT><FONT COLOR="#008000">/*     •0 = XML     •1 = HTML     •2 = PDF     •3 = ToHTML Stylesheet     •4 = ToXSLFO Stylesheet     •5 = XSD Schema     •6 = PrintPS     •7 = Excel     •8 = XSLFO     •9 = ToEXCEL     •10=xlsx     •11=TIFF     •12=pdfprint     •13=displayxlsx     •14=fo2pdf     •15=foandpdf   */      </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">xslfo</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Stream.TmpBinary</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()

      </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">t</FONT><FONT COLOR="#000000">=..</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">t</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">GenerateReportToStream</FONT><FONT COLOR="#000000">(.</FONT><FONT COLOR="#800000">xslfo</FONT><FONT COLOR="#000000">,4)   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">ReplaceStream</FONT><FONT COLOR="#000000">(.</FONT><FONT COLOR="#800000">xslfo</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">format</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">t</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">toxslfostream</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">xslfo   </FONT><FONT COLOR="#0000ff">d $system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">t</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">GenerateReport</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"c:\temp\test.pdf"</FONT><FONT COLOR="#000000">,2)) }</FONT>

  4. SAMPLES>##class(MyApp.ReportDemo).Test("I")
    or
    SAMPLES>##class(MyApp.ReportDemo).Test("01")
    or
    SAMPLES>##class(MyApp.ReportDemo).Test("A")
  5. open test.pdf. Profit!
Vitaliy Serdtsev · Jun 6, 2018 go to post

Choose to your taste:

<FONT COLOR="#000080">Class dc.test </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">Abstract </FONT><FONT COLOR="#000000">]
{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Public() [ </FONT><FONT COLOR="#000080">Internal</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">Private</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">ProcedureBlock </FONT><FONT COLOR="#000000">= 0 ] {   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">Choice0</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Sunday" </FONT><FONT COLOR="#ff0000">Choice1</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Monday" </FONT><FONT COLOR="#ff0000">Choice2</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Tuesday" </FONT><FONT COLOR="#ff0000">Choice3</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Wednesday" </FONT><FONT COLOR="#ff0000">Choice4</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Thursday" </FONT><FONT COLOR="#ff0000">Choice5</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Friday" </FONT><FONT COLOR="#ff0000">Choice6</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Saturday" </FONT><FONT COLOR="#ff0000">Choice</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">a</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"entry " </FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#008000">"error"   </FONT><FONT COLOR="#0000ff">return </FONT><FONT COLOR="#800000">a </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">/// d ##class(dc.test).Test() ClassMethod </FONT><FONT COLOR="#000000">Test() {   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$zd</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$h</FONT><FONT COLOR="#000000">,10)

  </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"1) "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$case</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">,                 0:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice0</FONT><FONT COLOR="#000000">,                 1:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice1</FONT><FONT COLOR="#000000">,                 2:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice2</FONT><FONT COLOR="#000000">,                 3:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice3</FONT><FONT COLOR="#000000">,                 4:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice4</FONT><FONT COLOR="#000000">,                 5:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice5</FONT><FONT COLOR="#000000">,                 6:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice6</FONT><FONT COLOR="#000000">,                 :</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice</FONT><FONT COLOR="#000000">),!

  </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"2) "</FONT><FONT COLOR="#000000">,@(</FONT><FONT COLOR="#008000">"$$Choice"</FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#0000ff">$case</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">,                               0:0,                               1:1,                               2:2,                               3:3,                               4:4,                               5:5,                               6:6,                               :</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">)),!

  </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"-"      </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"3) "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$case</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">,                 0:</FONT><FONT COLOR="#008000">"Sunday"</FONT><FONT COLOR="#000000">,                 1:</FONT><FONT COLOR="#008000">"Monday"</FONT><FONT COLOR="#000000">,                 2:</FONT><FONT COLOR="#008000">"Tuesday"</FONT><FONT COLOR="#000000">,                 3:</FONT><FONT COLOR="#008000">"Wednesday"</FONT><FONT COLOR="#000000">,                 4:</FONT><FONT COLOR="#008000">"Thursday"</FONT><FONT COLOR="#000000">,                 5:</FONT><FONT COLOR="#008000">"Friday"</FONT><FONT COLOR="#000000">,                 6:</FONT><FONT COLOR="#008000">"Saturday"</FONT><FONT COLOR="#000000">,                 :</FONT><FONT COLOR="#0000ff">$xecute</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"()"</FONT><FONT COLOR="#000000">_                           </FONT><FONT COLOR="#008000">" set a=""entry "" ""error"""</FONT><FONT COLOR="#000000">                           </FONT><FONT COLOR="#008000">" return a"</FONT><FONT COLOR="#000000">)),! }

}</FONT>

Vitaliy Serdtsev · Jun 4, 2018 go to post

Here is my solution, which has a number of advantages:

  1. there are no restrictions to the order of ID
  2. you can search in queries for the entire timestamp or for parts of it
  3. standard, reliable and proven Caché features are used
  4. this works very, very fast.

See my article for details: Indexing of non-atomic attributes

Class dc.TSOrder Extends (%Persistent%Populate)
{

</FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">Extent [ </FONT><FONT COLOR="#000080">Extent</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">Type </FONT><FONT COLOR="#000000">= bitmap ];

</FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iSmartTS On (TS(KEYS), TS(ELEMENTS));

</FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iTS On TS;

</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">TS </FONT><FONT COLOR="#000080">As %TimeStamp</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">MAXVAL </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"2016-07-31 23:59:59.999999"</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">MINVAL </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"2016-07-01 00:00:00.000000"</FONT><FONT COLOR="#000000">);

</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">Data </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">MAXLEN </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">200</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">MINLEN </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">100</FONT><FONT COLOR="#000000">);

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">TSBuildValueArray(   </FONT><FONT COLOR="#ff00ff">value</FONT><FONT COLOR="#000000">,   </FONT><FONT COLOR="#000080">ByRef </FONT><FONT COLOR="#ff00ff">array</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">i </FONT><FONT COLOR="#800000">value</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"" </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">(0)=</FONT><FONT COLOR="#800000">value   </FONT><FONT COLOR="#800080">}</FONT><FONT COLOR="#0000ff">else</FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">date</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">value</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">" "</FONT><FONT COLOR="#000000">,1),     </FONT><FONT COLOR="#800000">time</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">value</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">" "</FONT><FONT COLOR="#000000">,2),     </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"date"</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#800000">date</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"time"</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#800000">time</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"ddhh"</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">date</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"-"</FONT><FONT COLOR="#000000">,3)</FONT><FONT COLOR="#008000">"-"</FONT><FONT COLOR="#000000"></FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">time</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">":"</FONT><FONT COLOR="#000000">,1)   </FONT><FONT COLOR="#800080">}   </FONT><FONT COLOR="#0000ff">q $$$OK </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">/// d ##class(dc.TSOrder).Fill() ClassMethod </FONT><FONT COLOR="#000000">Fill(</FONT><FONT COLOR="#ff00ff">N </FONT><FONT COLOR="#000000">= {30e6}) {   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">%KillExtent</FONT><FONT COLOR="#000000">(), ..</FONT><FONT COLOR="#0000ff">Populate</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">N</FONT><FONT COLOR="#000000">), </FONT><FONT COLOR="#0000ff">$system</FONT><FONT COLOR="#008080">.SQL</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">TuneTable</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">(),</FONT><FONT COLOR="#0000ff">$$$YES</FONT><FONT COLOR="#000000">), </FONT><FONT COLOR="#0000ff">$system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Compile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">(),</FONT><FONT COLOR="#008000">"cu-d"</FONT><FONT COLOR="#000000">) }

}</FONT>

Results from SMP:

<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#000080">distinct null from </FONT><FONT COLOR="#008000">dc</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#008000">TSOrder </FONT><FONT COLOR="#000080">where </FONT><FONT COLOR="#008000">TS </FONT><FONT COLOR="#000000">between {</FONT><FONT COLOR="#000080">ts </FONT><FONT COLOR="#008080">'2016-07-01 00:00:00.00000'</FONT><FONT COLOR="#000000">} AND {</FONT><FONT COLOR="#000080">ts </FONT><FONT COLOR="#008080">'2016-07-01 23:59:59.999999'</FONT><FONT COLOR="#000000">}</FONT>

Performance: 2.339 seconds 2109755 global references 14768692 lines executed (the number of selected records is 968476, used the normal index)

<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#000080">distinct null from </FONT><FONT COLOR="#008000">dc</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#008000">TSOrder </FONT><FONT COLOR="#000080">where </FONT><FONT COLOR="#000000">for some %element(</FONT><FONT COLOR="#008000">TS</FONT><FONT COLOR="#000000">) (</FONT><FONT COLOR="#008000">%key</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008080">'date' </FONT><FONT COLOR="#000000">and </FONT><FONT COLOR="#008000">%value </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#008080">'2016-07-01'</FONT><FONT COLOR="#000000">)</FONT>

Performance: 2.269 seconds 1936962 global references 15496098 lines executed (the number of selected records is 968476, used the "smart" index)

<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#000080">distinct null from </FONT><FONT COLOR="#008000">dc</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#008000">TSOrder </FONT><FONT COLOR="#000080">where </FONT><FONT COLOR="#000000">for some %element(</FONT><FONT COLOR="#008000">TS</FONT><FONT COLOR="#000000">) (</FONT><FONT COLOR="#008000">%key</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008080">'ddhh' </FONT><FONT COLOR="#000000">and </FONT><FONT COLOR="#008000">%value </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#008080">'01-13'</FONT><FONT COLOR="#000000">)</FONT>

Performance: 0.096 seconds 80488 global references 644270 lines executed (the number of selected records is 40239, used the "smart" index)

Vitaliy Serdtsev · May 28, 2018 go to post

Try so:

<<FONT COLOR="#000080">tabGroup </FONT>... <FONT COLOR="#800000">onshowTab</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zenThis.refreshContents(true);"</FONT><FONT COLOR="#000000">>
</</FONT><FONT COLOR="#000080">tabGroup</FONT><FONT COLOR="#000000">></FONT>
Vitaliy Serdtsev · May 11, 2018 go to post

You can see the code examples and coding style in the sources of namespaces '%SYS' and/or 'SAMPLES'. But keep in mind that the style of classes written a long time ago differs significantly from style of classes written relatively recently, ex. [$ZT vs try/catch] or [%ResultSet vs %SQL.Statement]

Vitaliy Serdtsev · May 10, 2018 go to post

Localization in Caché DBMS

Simple example:

  1. <FONT COLOR="#000080">Class dc.test Extends %ZEN.Component.page
    </FONT><FONT COLOR="#000000">{
    

    </FONT><FONT COLOR="#000080">Parameter </FONT><FONT COLOR="#000000">DOMAIN = </FONT><FONT COLOR="#800080">"DCTEST"</FONT><FONT COLOR="#000000">;

    </FONT><FONT COLOR="#000080">XData </FONT><FONT COLOR="#000000">Contents [ </FONT><FONT COLOR="#000080">XMLNamespace </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"http://www.intersystems.com/zen" </FONT><FONT COLOR="#000000">] { <</FONT><FONT COLOR="#000080">page </FONT><FONT COLOR="#800000">xmlns</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"http://www.intersystems.com/zen"</FONT><FONT COLOR="#000000">>   <</FONT><FONT COLOR="#000080">radioSet </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"lng"     </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Текущий язык"     </FONT><FONT COLOR="#800000">layout</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"vertical"     </FONT><FONT COLOR="#800000">displayList</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Португальский,Русский"     </FONT><FONT COLOR="#800000">valueList</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"pt-br,ru"     </FONT><FONT COLOR="#800000">value</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"ru"     </FONT><FONT COLOR="#800000">onchange</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zenPage.changeLang(zenThis.value);"   </FONT><FONT COLOR="#000000">/>   <</FONT><FONT COLOR="#000080">form</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">text </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Описание" </FONT><FONT COLOR="#800000">required</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"true" </FONT><FONT COLOR="#800000">requiredMessage</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"обязательно." </FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">submit </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Сохранить"</FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">form</FONT><FONT COLOR="#000000">> </</FONT><FONT COLOR="#000080">page</FONT><FONT COLOR="#000000">> }

    </FONT><FONT COLOR="#000080">/// User clicked to change preferred language. ClientMethod </FONT><FONT COLOR="#000000">changeLang(</FONT><FONT COLOR="#ff00ff">lng</FONT><FONT COLOR="#000000">) [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">ok </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.SrvChangeLang(lng);   self.document.location.reload(); }

    </FONT><FONT COLOR="#000080">/// Change preferred language for this session and page ClassMethod </FONT><FONT COLOR="#000000">SrvChangeLang(</FONT><FONT COLOR="#ff00ff">lng</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Boolean </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">ZenMethod </FONT><FONT COLOR="#000000">] {   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">%session</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Language</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">lng   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">%response</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Language</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">lng   </FONT><FONT COLOR="#0000ff">q $$$YES </FONT><FONT COLOR="#000000">}

    </FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnAfterCreatePage() </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">%SetValueById</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"lng"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">%session</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Language</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">Quit $$$OK </FONT><FONT COLOR="#000000">}

    }</FONT>

  2. USER>##class(%MessageDictionary).ExportDomainList("messages_ru.xml","DCTEST","ru")

    Result (messages_ru.xml):

    <?xml <FONT COLOR="#008000">version</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"1.0" encoding</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"UTF-8"</FONT><FONT COLOR="#000000">?> <</FONT><FONT COLOR="#000080">MsgFile </FONT><FONT COLOR="#800000">Language</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"ru"</FONT><FONT COLOR="#000000">>    <</FONT><FONT COLOR="#000080">MsgDomain </FONT><FONT COLOR="#800000">Domain</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"DCTEST"</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"358179803"</FONT><FONT COLOR="#000000">>Текущий язык</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"1805419696"</FONT><FONT COLOR="#000000">>Португальский,Русский</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"2153752096"</FONT><FONT COLOR="#000000">>Описание</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"2835101332"</FONT><FONT COLOR="#000000">>обязательно.</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"3683485237"</FONT><FONT COLOR="#000000">>Сохранить</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>    </</FONT><FONT COLOR="#000080">MsgDomain</FONT><FONT COLOR="#000000">> </</FONT><FONT COLOR="#000080">MsgFile</FONT><FONT COLOR="#000000">></FONT>

  3. messages_pt-br.xml:
    

    <?xml <FONT COLOR="#008000">version</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"1.0" encoding</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"UTF-8"</FONT><FONT COLOR="#000000">?> <</FONT><FONT COLOR="#000080">MsgFile </FONT><FONT COLOR="#800000">Language</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"pt-br"</FONT><FONT COLOR="#000000">>    <</FONT><FONT COLOR="#000080">MsgDomain </FONT><FONT COLOR="#800000">Domain</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"DCTEST"</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"358179803"</FONT><FONT COLOR="#000000">>Idioma atual</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"1805419696"</FONT><FONT COLOR="#000000">>Português,Russo</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"2153752096"</FONT><FONT COLOR="#000000">>Descrição</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"2835101332"</FONT><FONT COLOR="#000000">>é obrigatório.</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">Message </FONT><FONT COLOR="#800000">Id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"3683485237"</FONT><FONT COLOR="#000000">>Salvar</</FONT><FONT COLOR="#000080">Message</FONT><FONT COLOR="#000000">>    </</FONT><FONT COLOR="#000080">MsgDomain</FONT><FONT COLOR="#000000">> </</FONT><FONT COLOR="#000080">MsgFile</FONT><FONT COLOR="#000000">></FONT>

    USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%MessageDictionary</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Import</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"messages_pt-br.xml"</FONT><FONT COLOR="#000000">)</FONT>

  4. Profit!
Vitaliy Serdtsev · May 7, 2018 go to post
USER>w $zv
Cache for Windows (x86-32) 2015.2 (Build 664_3U) Wed Aug 12 2015 12:29:34 EDT
The date is saved to the database correctly.
Class dc.A Extends %Persistent

</FONT><FONT COLOR="#000000">{ </FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">DOB </FONT><FONT COLOR="#000080">As %Date</FONT><FONT COLOR="#000000">; }</FONT>

<FONT COLOR="#000080">Class dc.MVC.A Extends %ZEN.DataModel.ObjectDataModel </FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">DOB </FONT><FONT COLOR="#000080">As %Date</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">ZENATTRS </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"id:DOB|format:DMY|separator:/"</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">ZENCONTROL </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"dateText"</FONT><FONT COLOR="#000000">);

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnNewSource(</FONT><FONT COLOR="#000080">Output </FONT><FONT COLOR="#ff00ff">pSC </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">= {</FONT><FONT COLOR="#0000ff">$$$OK</FONT><FONT COLOR="#000000">}) </FONT><FONT COLOR="#000080">As %RegisteredObject </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">dc.A</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">() }

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnOpenSource(   </FONT><FONT COLOR="#ff00ff">pID </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">,   </FONT><FONT COLOR="#ff00ff">pConcurrency </FONT><FONT COLOR="#000080">As %Integer </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">-1</FONT><FONT COLOR="#000000">,   </FONT><FONT COLOR="#000080">Output </FONT><FONT COLOR="#ff00ff">pSC </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">= {</FONT><FONT COLOR="#0000ff">$$$OK</FONT><FONT COLOR="#000000">}) </FONT><FONT COLOR="#000080">As %RegisteredObject </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">dc.A</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%OpenId</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">pID</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">pConcurrency</FONT><FONT COLOR="#000000">,.</FONT><FONT COLOR="#800000">pSC</FONT><FONT COLOR="#000000">) }

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnSaveSource(</FONT><FONT COLOR="#ff00ff">pSource </FONT><FONT COLOR="#000080">As dc.A</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#800000">pSource</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Save</FONT><FONT COLOR="#000000">() }

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">%OnDeleteSource(</FONT><FONT COLOR="#ff00ff">pID </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">dc.A</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%DeleteId</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">pID</FONT><FONT COLOR="#000000">) }

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnLoadModel(</FONT><FONT COLOR="#ff00ff">pSource </FONT><FONT COLOR="#000080">As dc.A</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">DOB </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800000">pSource</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DOB   q $$$OK </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnStoreModel(</FONT><FONT COLOR="#ff00ff">pSource </FONT><FONT COLOR="#000080">As dc.A</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">pSource</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DOB </FONT><FONT COLOR="#000000">= ..</FONT><FONT COLOR="#0000ff">DOB   q $$$OK </FONT><FONT COLOR="#000000">}

}</FONT>

<FONT COLOR="#000080">Class dc.test Extends %ZEN.Component.page </FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">XData </FONT><FONT COLOR="#000000">Contents [ </FONT><FONT COLOR="#000080">XMLNamespace </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"http://www.intersystems.com/zen" </FONT><FONT COLOR="#000000">] {   <</FONT><FONT COLOR="#000080">page </FONT><FONT COLOR="#800000">xmlns</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"http://www.intersystems.com/zen"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">dataController </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"a-controller" </FONT><FONT COLOR="#800000">modelClass</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"dc.MVC.A" </FONT><FONT COLOR="#800000">modelId</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">dynaForm </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"a-form"  </FONT><FONT COLOR="#800000">controllerId</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"a-controller"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Save" </FONT><FONT COLOR="#800000">onclick</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zen('a-form').save();" </FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">page</FONT><FONT COLOR="#000000">> }

}</FONT>

Vitaliy Serdtsev · Apr 25, 2018 go to post

Still can be so:

<FONT COLOR="#000080">Class dc.test </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">Abstract </FONT><FONT COLOR="#000000">]
{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test(</FONT><FONT COLOR="#ff00ff">s </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"#"</FONT><FONT COLOR="#000000">) {   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Test_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">mac() [ </FONT><FONT COLOR="#000080">ProcedureBlock </FONT><FONT COLOR="#000000">= 0 ] { </FONT><FONT COLOR="#ff0000">sub1</FONT><FONT COLOR="#000000">(s=1)   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"sub1_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">sub2</FONT><FONT COLOR="#000000">(s=2)   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"sub2_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">procPrivate</FONT><FONT COLOR="#000000">(s=3) </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"procPrivate_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s </FONT><FONT COLOR="#800080">} </FONT><FONT COLOR="#ff0000">procPublic</FONT><FONT COLOR="#000000">(s=3) </FONT><FONT COLOR="#0000ff">public </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"procPublic_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s </FONT><FONT COLOR="#800080">} </FONT><FONT COLOR="#000000">}

}</FONT>

Result:
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">zTest</FONT><FONT COLOR="#000000">^dc.test.1(1)</FONT>
Test_1
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">sub1</FONT><FONT COLOR="#000000">^dc.test.1</FONT>
sub1_1
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">sub2</FONT><FONT COLOR="#000000">^dc.test.1</FONT>
sub2_2
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">sub1</FONT><FONT COLOR="#000000">^dc.test.1(10)</FONT>
sub1_10
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">sub2</FONT><FONT COLOR="#000000">^dc.test.1(10)</FONT>
sub2_10
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">procPrivate</FONT><FONT COLOR="#000000">^dc.test.1(10)</FONT>

D procPrivate^dc.test.1(10) ^ <NOLINE> USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">procPublic</FONT><FONT COLOR="#000000">^dc.test.1(10)</FONT> procPublic_10 USER>

Vitaliy Serdtsev · Apr 23, 2018 go to post

This can be done also in the CLS.

<FONT COLOR="#ff0000">TEST</FONT><FONT COLOR="#000000">(invar) [outvar] </FONT><FONT COLOR="#0000ff">public </FONT><FONT COLOR="#800080">{

}</FONT>

=>
<FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">TEST(</FONT><FONT COLOR="#ff00ff">invar</FONT><FONT COLOR="#000000">) [</FONT><FONT COLOR="#000080">PublicList</FONT><FONT COLOR="#000000">=outvar] {

}</FONT>

PublicList
Vitaliy Serdtsev · Apr 14, 2018 go to post

%PosixTime

%PosixTime is preferable to %TimeStamp, because it takes up less disk space and memory than the %TimeStamp data type and provides better performance than %TimeStamp.proof
Vitaliy Serdtsev · Apr 6, 2018 go to post

My best result is <FONT COLOR=red>77726967</FONT> so far.

<FONT COLOR="#000080">Class ITPlanet.Task4 </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">Abstract </FONT><FONT COLOR="#000000">]
{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">main(</FONT><FONT COLOR="#ff00ff">s </FONT><FONT COLOR="#000080">As %Integer </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">10</FONT><FONT COLOR="#000000">) {  </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">x</FONT><FONT COLOR="#000000">=1:1:</FONT><FONT COLOR="#800000">s </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">! </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">y</FONT><FONT COLOR="#000000">=1:1:</FONT><FONT COLOR="#800000">s </FONT><FONT COLOR="#0000ff">w $c</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">y</FONT><FONT COLOR="#000000">#</FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000"><2!</FONT><FONT COLOR="#0000ff">$lf</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$lb</FONT><FONT COLOR="#000000">(1,</FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">y</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">-</FONT><FONT COLOR="#800000">y</FONT><FONT COLOR="#000000">+1),</FONT><FONT COLOR="#800000">x</FONT><FONT COLOR="#000000">)*3+32)</FONT> <FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">length(   </FONT><FONT COLOR="#ff00ff">class </FONT><FONT COLOR="#000000">= {</FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">()},   </FONT><FONT COLOR="#ff00ff">method </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"main"</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Integer </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">CodeMode </FONT><FONT COLOR="#000000">= expression ] { </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Dictionary.MethodDefinition</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">IDKEYOpen</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">class</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#800000">method</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Implementation</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Size </FONT><FONT COLOR="#000000">}

}</FONT>

USER><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">ITPlanet.Task4</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">length</FONT><FONT COLOR="#000000">()</FONT> 67 USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">ITPlanet.Task4</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">main</FONT><FONT COLOR="#000000">(11)</FONT>

###########

# #

# #

# #

#

# #

# #

# #

###########

Vitaliy Serdtsev · Mar 27, 2018 go to post

Make two changes to your code:

  1. <FONT COLOR="#000080">/// return json
    Method </FONT><FONT COLOR="#000000">infoJson() </FONT><FONT COLOR="#000080">As %String </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">WebMethod </FONT><FONT COLOR="#000000">]
    {
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">webservice.SOAPResponse</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">CustomerID</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"1"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Name</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"2"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Street</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"3"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">City</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"4"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">State</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"5"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Zip</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"6"
    

        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Stream.TmpBinary</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()     </FONT><FONT COLOR="#0000ff">do </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%ZEN.Auxiliary.jsonProvider</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%WriteJSONStreamFromObject</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">,,,</FONT><FONT COLOR="#0000ff">$$$YES</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"s"</FONT><FONT COLOR="#000000">)     </FONT><FONT COLOR="#0000ff">quit </FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Read</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$$$MaxStringLength</FONT><FONT COLOR="#000000">) }</FONT>

  2. <FONT COLOR="#000080">/// write ##class(PRD.Test).test1()
    ClassMethod </FONT><FONT COLOR="#000000">test1() </FONT><FONT COLOR="#000080">As %String
    </FONT><FONT COLOR="#000000">{
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">webservice.SOAPResponse</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">CustomerID</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"1"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Name</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"2"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Street</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"3"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">City</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"4"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">State</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"5"
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Zip</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"6"
        
        </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Stream.TmpBinary</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()
        </FONT><FONT COLOR="#0000ff">do </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%ZEN.Auxiliary.jsonProvider</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%WriteJSONStreamFromObject</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">soapresponse</FONT><FONT COLOR="#000000">,,,</FONT><FONT COLOR="#0000ff">$$$YES</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"s"</FONT><FONT COLOR="#000000">)
        </FONT><FONT COLOR="#0000ff">quit </FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Read</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$$$MaxStringLength</FONT><FONT COLOR="#000000">)
    }</FONT>