Vitaliy Serdtsev · Feb 2, 2018 go to post
Please note that the option with %INLIST does not yet use “collection” indexes, and will therefore be slower than the one provided above proof
Vitaliy Serdtsev · Dec 29, 2017 go to post

Undefined variable and the variable contains "" (null) is two different situations, e.g. (see $DATA):

<FONT COLOR="#0000ff">kill </FONT><FONT COLOR="#800000">myObj
</FONT><FONT COLOR="#0000ff">write $data</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">myObj</FONT><FONT COLOR="#000000">),! </FONT><FONT COLOR="#008000">; -> 0
</FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">myObj</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$$$NULLOREF
write $data</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">myObj</FONT><FONT COLOR="#000000">),! </FONT><FONT COLOR="#008000">; -> 1</FONT>
In your case it would be better to use $IsObject:
<FONT COLOR="#0000ff">kill </FONT><FONT COLOR="#800000">myObj
</FONT><FONT COLOR="#0000ff">write $IsObject</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">myObj</FONT><FONT COLOR="#000000">),! </FONT><FONT COLOR="#008000">; -> 0
</FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">d</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$$$NULLOREF
write $IsObject</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">myObj</FONT><FONT COLOR="#000000">),! </FONT><FONT COLOR="#008000">; -> 0
</FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">myObj</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#ff00ff">{}
</FONT><FONT COLOR="#0000ff">write $IsObject</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">myObj</FONT><FONT COLOR="#000000">),! </FONT><FONT COLOR="#008000">; -> 1</FONT>
Accordingly, should be <FONT COLOR="#0000ff">do $$$AssertTrue</FONT><FONT COLOR="#000000">('</FONT><FONT COLOR="#0000ff">$IsObject</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">myObj</FONT><FONT COLOR="#000000">), </FONT><FONT COLOR="#008000">"myObj is null"</FONT><FONT COLOR="#000000">)</FONT>
Vitaliy Serdtsev · Dec 29, 2017 go to post

You are right, the macro $$$NULL present only in %sqlMigration.inc and this is not the file that developers often include to its project.
I prefer to use the macro $$$NULLOREF/$$$NULLOID from %occExtent.inc, which is available by default in the class that inherits from %Library.Base, and for routines is enough to include %systemInclude.inc.

Vitaliy Serdtsev · Dec 28, 2017 go to post

Why so difficult?
This similarly following condition:

<FONT COLOR="#000080">WHERE 
</FONT><FONT COLOR="#000000">(
</FONT><FONT COLOR="#008000">year</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#808000">current_date</FONT><FONT COLOR="#000000">) - </FONT><FONT COLOR="#008000">year</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">DOB</FONT><FONT COLOR="#000000">)
) >= 13</FONT>
It Besides above was already indicated, why does not follow to use such a code, for example:
<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#808000">datediff</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">year</FONT><FONT COLOR="#000000">,
</FONT><FONT COLOR="#808000">todate</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#808000">to_char</FONT><FONT COLOR="#000000">({</FONT><FONT COLOR="#000080">d </FONT><FONT COLOR="#008080">'1990-12-31'</FONT><FONT COLOR="#000000">},</FONT><FONT COLOR="#008080">'YYYY'</FONT><FONT COLOR="#000000">)||</FONT><FONT COLOR="#008080">':1'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'YYYY:MM'</FONT><FONT COLOR="#000000">), -- birthday
</FONT><FONT COLOR="#808000">todate</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#808000">to_char</FONT><FONT COLOR="#000000">({</FONT><FONT COLOR="#000080">d </FONT><FONT COLOR="#008080">'2003-01-01'</FONT><FONT COLOR="#000000">},</FONT><FONT COLOR="#008080">'YYYY'</FONT><FONT COLOR="#000000">)||</FONT><FONT COLOR="#008080">':1'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'YYYY:MM'</FONT><FONT COLOR="#000000">) -- report date
)</FONT>
This gives an incorrect result - 13, although it should be 12.
Vitaliy Serdtsev · Dec 26, 2017 go to post

Here's another way (without PlaceAfter):

<FONT COLOR="#000080">Class Macro.Child Extends Macro.Parent
</FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">%inc() [ </FONT><FONT COLOR="#000080">Internal</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">Private </FONT><FONT COLOR="#000000">] {   </FONT><FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">Child }

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test() {   </FONT><FONT COLOR="#0000ff">write </FONT><FONT COLOR="#008000">"Class: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">() , ! , </FONT><FONT COLOR="#008000">"Value: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$$$name </FONT><FONT COLOR="#000000">}

}</FONT>

Vitaliy Serdtsev · Dec 26, 2017 go to post

The key difference of $classmethod is runtime:

$CLASSMETHOD permits a ObjectScript program to invoke an arbitrary class method in an arbitrary class. Both the class name and the method name may be computed at runtime or supplied as string constants.proof
Vitaliy Serdtsev · Dec 26, 2017 go to post
Class include is not required (and does not seem to affect anything) and can be omitted
Yeah, I just forgot to delete that line.
Vitaliy Serdtsev · Dec 26, 2017 go to post

Then this:

<FONT COLOR="#000080">Include </FONT><FONT COLOR="#ff0000">Child

</FONT><FONT COLOR="#000080">Class Macro.Child Extends Macro.Parent </FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">first() {   </FONT><FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">Child }

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test() [ </FONT><FONT COLOR="#000080">PlaceAfter </FONT><FONT COLOR="#000000">= first ] {   </FONT><FONT COLOR="#0000ff">write </FONT><FONT COLOR="#008000">"Class: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">() , ! , </FONT><FONT COLOR="#008000">"Value: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$$$name </FONT><FONT COLOR="#000000">}

}</FONT>

or this:
<FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test()
{
  </FONT><FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">Child
  </FONT><FONT COLOR="#0000ff">write </FONT><FONT COLOR="#008000">"Class: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">() , ! , </FONT><FONT COLOR="#008000">"Value: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$$$name
</FONT><FONT COLOR="#000000">}</FONT>
Vitaliy Serdtsev · Dec 26, 2017 go to post

Macro.Parent.cls:

<FONT COLOR="#000080">Include </FONT><FONT COLOR="#ff0000">Parent

</FONT><FONT COLOR="#000080">Class Macro.Parent </FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test() {   </FONT><FONT COLOR="#0000ff">write </FONT><FONT COLOR="#008000">"Class: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">() , ! , </FONT><FONT COLOR="#008000">"Value: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$$$name </FONT><FONT COLOR="#000000"> }

}</FONT>

Macro.Child.cls:
<FONT COLOR="#000080">Include </FONT><FONT COLOR="#ff0000">Child

</FONT><FONT COLOR="#000080">Class Macro.Child Extends Macro.Parent </FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test() {   </FONT><FONT COLOR="#0000ff">write </FONT><FONT COLOR="#008000">"Class: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">() , ! , </FONT><FONT COLOR="#008000">"Value: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$$$name </FONT><FONT COLOR="#000000"> }

}</FONT>

Parent.inc:
<FONT COLOR="#0000ff">#ifndef </FONT><FONT COLOR="#000000">name
  </FONT><FONT COLOR="#0000ff">#define </FONT><FONT COLOR="#000000">name </FONT><FONT COLOR="#008000">"Parent"
</FONT><FONT COLOR="#0000ff">#endif name</FONT>
Child.inc:
<FONT COLOR="#0000ff">#define </FONT><FONT COLOR="#000000">name </FONT><FONT COLOR="#008000">"Child"</FONT>
Result:
>do ##class(Macro.Parent).Test()
Class: Macro.Parent
Value: Parent

do ##class(Macro.Child).Test() Class: Macro.Child Value: Child

Vitaliy Serdtsev · Dec 19, 2017 go to post

This data is saved in the registry. You can even save greater value than allowed by the program (see screenshot).

Example of work with the registry directly from Caché Object Script can be found here.

Vitaliy Serdtsev · Dec 16, 2017 go to post

For better performance you should make a few changes:

  1. add an index on DOB field
  2. rebuild the index and run TuneTable
  3. modify the query
    select DOB from HSAA.Patient
    where
    dob<=dateadd('yy',-13,current_date)
    or dob between
          todate((year(current_date)-13)||'0101','yyyymmdd')
      and todate((year(current_date)-13)||'1231','yyyymmdd')
The result will pleasantly surprise you.
Vitaliy Serdtsev · Dec 15, 2017 go to post

Hi Marco.

CSVTOCLASS creates a new class if it doesn't already exist and then it calls the Import method.

Since you already have created the class, it is not created, but there is no Import method, so nothing works.

Solution:
  1. delete all previously created classes: ZenImport.Country, TestCsv.Csv, etc.
  2. run in terminal:
    USER>set rowtype "Code VARCHAR(2),Name VARCHAR(9)"
    USER>set filename "c:\temp\Country.csv"
    USER>do ##class(%SQL.Util.Procedures).CSVTOCLASS(2, .rowtypefilename,";",,,"Test.CSV")
  3. run in Portal:
    select * from Test.CSV
    open and see the class "Test.CSV". Profit!!!
Vitaliy Serdtsev · Dec 14, 2017 go to post
select DOB from sample.person -- or HSAA.Patient
where
(tochar(current_date,'YYYYMMDD')-tochar(DOB,'YYYYMMDD'))\10000>=13
or ((year(current_date)||'1231')-tochar(DOB,'YYYYMMDD'))\10000=13
Vitaliy Serdtsev · Dec 5, 2017 go to post

In this case $system.SQL.DATEDIFF is not suitable:

USER><FONT COLOR="#0000ff">w $system</FONT><FONT COLOR="#008080">.SQL</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DATEDIFF</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"yy"</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$zdh</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"30.12.1990"</FONT><FONT COLOR="#000000">,4), </FONT><FONT COLOR="#0000ff">$zdh</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"01.01.1991"</FONT><FONT COLOR="#000000">,4))</FONT>
1

USER><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$ZD</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$zdh</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"01.01.1991"</FONT><FONT COLOR="#000000">,4),8)-</FONT><FONT COLOR="#0000ff">$ZD</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$zdh</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"30.12.1990"</FONT><FONT COLOR="#000000">,4),8))\10000</FONT> 0

Vitaliy Serdtsev · Dec 5, 2017 go to post

See Sample.Person in "SAMPLES".

<FONT COLOR="#000080">/// Person's age.<br>
/// This is a calculated field whose value is derived from <property>DOB</property>.
Property </FONT><FONT COLOR="#000000">Age </FONT><FONT COLOR="#000080">As %Integer </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">Calculated</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">SqlComputeCode </FONT><FONT COLOR="#000000">= { </FONT><FONT COLOR="#0000ff">Set </FONT><FONT COLOR="#800080">{Age}</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">Sample.Person</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">CurrentAge</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800080">{DOB}</FONT><FONT COLOR="#000000">)}, </FONT><FONT COLOR="#000080">SqlComputed</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">SqlComputeOnChange </FONT><FONT COLOR="#000000">= DOB ];</FONT>

<FONT COLOR="#000080">/// This class method calculates a current age given a date of birth <var>date</var>. ClassMethod </FONT><FONT COLOR="#000000">CurrentAge(</FONT><FONT COLOR="#ff00ff">date </FONT><FONT COLOR="#000080">As %Date </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">""</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="#0000ff">$Select</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">date</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">,1:(</FONT><FONT COLOR="#0000ff">$ZD</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$H</FONT><FONT COLOR="#000000">,8)-</FONT><FONT COLOR="#0000ff">$ZD</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">date</FONT><FONT COLOR="#000000">,8)\10000)) }</FONT>

Vitaliy Serdtsev · Nov 17, 2017 go to post

All correctly, this is what I had in mind.

Quote:

The Find Global String page enables you to find a given string in the subscripts1 or in the values2 of selected3 globals.

You can select all the globals of the namespace. In this case, the search will be performed across the database. In the search results you will get including the name of global.

Vitaliy Serdtsev · Nov 14, 2017 go to post
  1. Asynchronous uploading only one file
    Class upload.fileOne Extends %ZEN.Component.page
    {
    

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

    </FONT><FONT COLOR="#000080">XData </FONT><FONT COLOR="#000000">Style {   <</FONT><FONT COLOR="#000080">style </FONT><FONT COLOR="#800000">type</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"text/css"</FONT><FONT COLOR="#000000">>   </</FONT><FONT COLOR="#000080">style</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="#800000">title</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Upload file using XMLHttpRequest" </FONT><FONT COLOR="#800000">labelPosition</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"left"</FONT><FONT COLOR="#000000">>   <</FONT><FONT COLOR="#000080">hgroup </FONT><FONT COLOR="#800000">cellVAlign</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"bottom"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">fileUpload </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Select the file" </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"fileToUpload" </FONT><FONT COLOR="#800000">onchange</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zenPage.fileSelected()"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Upload" </FONT><FONT COLOR="#800000">onclick</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zenPage.uploadFile();"</FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">hgroup</FONT><FONT COLOR="#000000">>   <</FONT><FONT COLOR="#000080">label </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"fileType" </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Type: "</FONT><FONT COLOR="#000000">/>   <</FONT><FONT COLOR="#000080">label </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"fileName" </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Name: "</FONT><FONT COLOR="#000000">/>   <</FONT><FONT COLOR="#000080">label </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"fileSize" </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Size: "</FONT><FONT COLOR="#000000">/>   <</FONT><FONT COLOR="#000080">html</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">div </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"progressNumber"</FONT><FONT COLOR="#000000">>%</</FONT><FONT COLOR="#000080">div</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">progress </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"progressValue" </FONT><FONT COLOR="#800000">value</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"0" </FONT><FONT COLOR="#800000">max</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"100.0"</FONT><FONT COLOR="#000000">></</FONT><FONT COLOR="#000080">progress</FONT><FONT COLOR="#000000">>   </</FONT><FONT COLOR="#000080">html</FONT><FONT COLOR="#000000">> </</FONT><FONT COLOR="#000080">page</FONT><FONT COLOR="#000000">> }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">uploadFile() [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">fd </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">new </FONT><FONT COLOR="#000000">FormData();   fd.append(</FONT><FONT COLOR="#800000">'fUpload'</FONT><FONT COLOR="#000000">, zen(</FONT><FONT COLOR="#800000">'fileToUpload'</FONT><FONT COLOR="#000000">).findElement(</FONT><FONT COLOR="#800000">'control'</FONT><FONT COLOR="#000000">).files[</FONT><FONT COLOR="#000080">0</FONT><FONT COLOR="#000000">]);   </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">xhr </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">new </FONT><FONT COLOR="#000000">XMLHttpRequest();   xhr.upload.addEventListener(</FONT><FONT COLOR="#800000">'progress'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.uploadProgress, false);   xhr.addEventListener(</FONT><FONT COLOR="#800000">'load'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.uploadComplete, false);   xhr.addEventListener(</FONT><FONT COLOR="#800000">'error'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.uploadFailed, false);   xhr.addEventListener(</FONT><FONT COLOR="#800000">'abort'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.uploadCanceled, false);   xhr.open(</FONT><FONT COLOR="#800000">'POST'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#800000">'upload.fileOne.cls'</FONT><FONT COLOR="#000000">);   xhr.send(fd); }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">uploadProgress(</FONT><FONT COLOR="#ff00ff">evt</FONT><FONT COLOR="#000000">) [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   </FONT><FONT COLOR="#008000">if </FONT><FONT COLOR="#000000">(evt.lengthComputable) {     </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">percentComplete </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">Math.round(evt.loaded </FONT><FONT COLOR="#000080">* 100 / </FONT><FONT COLOR="#000000">evt.total);

        document.getElementById(</FONT><FONT COLOR="#800000">'progressNumber'</FONT><FONT COLOR="#000000">).innerHTML </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">percentComplete.toString() </FONT><FONT COLOR="#000080">+ </FONT><FONT COLOR="#800000">'%'</FONT><FONT COLOR="#000000">;     document.getElementById(</FONT><FONT COLOR="#800000">'progressValue'</FONT><FONT COLOR="#000000">).value </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">percentComplete;   }   </FONT><FONT COLOR="#008000">else </FONT><FONT COLOR="#000000">{     document.getElementById(</FONT><FONT COLOR="#800000">'progressNumber'</FONT><FONT COLOR="#000000">).innerHTML </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">$$$Text(</FONT><FONT COLOR="#800000">'Cannot compute'</FONT><FONT COLOR="#000000">);   } }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">uploadComplete(</FONT><FONT COLOR="#ff00ff">evt</FONT><FONT COLOR="#000000">) [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   zenAlert($$$Text(</FONT><FONT COLOR="#800000">'The upload is complete.'</FONT><FONT COLOR="#000000">)); }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">uploadFailed(</FONT><FONT COLOR="#ff00ff">evt</FONT><FONT COLOR="#000000">) [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   zenAlert($$$Text(</FONT><FONT COLOR="#800000">'An error occurred when trying to upload the file.'</FONT><FONT COLOR="#000000">)); }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">uploadCanceled(</FONT><FONT COLOR="#ff00ff">evt</FONT><FONT COLOR="#000000">) [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   zenAlert($$$Text(</FONT><FONT COLOR="#800000">'The upload was canceled by the user or the browser dropped the connection.'</FONT><FONT COLOR="#000000">)); }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">fileSelected() [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">file </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">zen(</FONT><FONT COLOR="#800000">'fileToUpload'</FONT><FONT COLOR="#000000">).findElement(</FONT><FONT COLOR="#800000">'control'</FONT><FONT COLOR="#000000">).files[</FONT><FONT COLOR="#000080">0</FONT><FONT COLOR="#000000">];   </FONT><FONT COLOR="#008000">if </FONT><FONT COLOR="#000000">(file) {

        </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">fileSize </FONT><FONT COLOR="#000080">= 0</FONT><FONT COLOR="#000000">;     </FONT><FONT COLOR="#008000">if </FONT><FONT COLOR="#000000">(file.size </FONT><FONT COLOR="#000080">> 1024  1024</FONT><FONT COLOR="#000000">)        fileSize </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">(Math.round(file.size </FONT><FONT COLOR="#000080"> 100 / </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">1024  1024</FONT><FONT COLOR="#000000">)) </FONT><FONT COLOR="#000080">/ 100</FONT><FONT COLOR="#000000">).toString() </FONT><FONT COLOR="#000080">+ </FONT><FONT COLOR="#000000">$$$Text(</FONT><FONT COLOR="#800000">'MB'</FONT><FONT COLOR="#000000">);     </FONT><FONT COLOR="#008000">else        </FONT><FONT COLOR="#000000">fileSize </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">(Math.round(file.size </FONT><FONT COLOR="#000080"> 100 / 1024</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">/ 100</FONT><FONT COLOR="#000000">).toString() </FONT><FONT COLOR="#000080">+ </FONT><FONT COLOR="#000000">$$$Text(</FONT><FONT COLOR="#800000">'KB'</FONT><FONT COLOR="#000000">);

        zenSetProp(</FONT><FONT COLOR="#800000">'fileType'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'value'</FONT><FONT COLOR="#000000">,file.type);     zenSetProp(</FONT><FONT COLOR="#800000">'fileName'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'value'</FONT><FONT COLOR="#000000">,file.name);     zenSetProp(</FONT><FONT COLOR="#800000">'fileSize'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'value'</FONT><FONT COLOR="#000000">,fileSize);         } }

    </FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">%OnPreHTTP() </FONT><FONT COLOR="#000080">As %Boolean </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">ServerOnly </FONT><FONT COLOR="#000000">= 1 ] {   </FONT><FONT COLOR="#0000ff">#dim </FONT><FONT COLOR="#800000">%request </FONT><FONT COLOR="#0000ff">As </FONT><FONT COLOR="#008080">%CSP.Request   </FONT><FONT COLOR="#0000ff">#dim </FONT><FONT COLOR="#800000">stream </FONT><FONT COLOR="#0000ff">As </FONT><FONT COLOR="#008080">%CSP.BinaryStream</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">%request</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">GetMimeData</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"fUpload"</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">if $IsObject</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#800080">{          </FONT><FONT COLOR="#008000">#; here you do with the received file useful work          /*     set ^tmp("filename")=stream.FileName     set ^tmp("filesize")=stream.Size     */          </FONT><FONT COLOR="#0000ff">quit $$$NO   </FONT><FONT COLOR="#800080">}   </FONT><FONT COLOR="#0000ff">quit $$$YES </FONT><FONT COLOR="#000000">}

    }</FONT>

  2. Asynchronous uploading immediately of several files
    <FONT COLOR="#000080">Class upload.fileMany Extends %ZEN.Component.page
    </FONT><FONT COLOR="#000000">{
    

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

    </FONT><FONT COLOR="#000080">XData </FONT><FONT COLOR="#000000">Style { <</FONT><FONT COLOR="#000080">style </FONT><FONT COLOR="#800000">type</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"text/css"</FONT><FONT COLOR="#000000">>   </FONT><FONT COLOR="#800000">.</FONT><FONT COLOR="#000080">ok </FONT><FONT COLOR="#800000">{     </FONT><FONT COLOR="#000080">color</FONT><FONT COLOR="#800000">:</FONT><FONT COLOR="#000080">green</FONT><FONT COLOR="#800000">;   }

      </FONT><FONT COLOR="#000000">#dropZone </FONT><FONT COLOR="#800000">{     </FONT><FONT COLOR="#000080">width</FONT><FONT COLOR="#800000">: 360px;     </FONT><FONT COLOR="#000080">height</FONT><FONT COLOR="#800000">: 125px;     </FONT><FONT COLOR="#000080">border</FONT><FONT COLOR="#800000">: </FONT><FONT COLOR="#000080">dashed </FONT><FONT COLOR="#800000">2px #ccc;     </FONT><FONT COLOR="#000080">background-color</FONT><FONT COLOR="#800000">: #fefefe;     </FONT><FONT COLOR="#000080">color</FONT><FONT COLOR="#800000">: #ccc;     </FONT><FONT COLOR="#000080">text-align</FONT><FONT COLOR="#800000">: </FONT><FONT COLOR="#000080">center</FONT><FONT COLOR="#800000">;     </FONT><FONT COLOR="#000080">padding</FONT><FONT COLOR="#800000">: 125px 0 0 0;   }

    </FONT><FONT COLOR="#000000"></</FONT><FONT COLOR="#000080">style</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="#800000">title</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Upload immediately multiple files using XMLHttpRequest"</FONT><FONT COLOR="#000000">>   <</FONT><FONT COLOR="#000080">html </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"dropZone"</FONT><FONT COLOR="#000000">>Drag files here or click below</</FONT><FONT COLOR="#000080">html</FONT><FONT COLOR="#000000">>   <</FONT><FONT COLOR="#000080">hgroup </FONT><FONT COLOR="#800000">cellVAlign</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"bottom"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">html </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"selectFiles" </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Choose the files"</FONT><FONT COLOR="#000000">>       <</FONT><FONT COLOR="#000080">input </FONT><FONT COLOR="#800000">type</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"file" </FONT><FONT COLOR="#800000">class</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"fileUpload" </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"fileToUpload" </FONT><FONT COLOR="#800000">onchange</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zenPage.fileSelected(document.getElementById('fileToUpload').files)" </FONT><FONT COLOR="#800000">multiple</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"multiple" </FONT><FONT COLOR="#000000">/>     </</FONT><FONT COLOR="#000080">html</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Clear" </FONT><FONT COLOR="#800000">title</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Clear the queue" </FONT><FONT COLOR="#800000">onclick</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zenPage.clearList();"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">spacer </FONT><FONT COLOR="#800000">width</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"10"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Upload" </FONT><FONT COLOR="#800000">title</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Upload files to the server" </FONT><FONT COLOR="#800000">onclick</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zenPage.uploadFile();"</FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">hgroup</FONT><FONT COLOR="#000000">>   <</FONT><FONT COLOR="#000080">fieldSet </FONT><FONT COLOR="#800000">legend</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Files waiting to upload"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">html </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"holder"</FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">fieldSet</FONT><FONT COLOR="#000000">> </</FONT><FONT COLOR="#000080">page</FONT><FONT COLOR="#000000">> }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">clearList() [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   fileQueue</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#000000">[];   zen(</FONT><FONT COLOR="#800000">'holder'</FONT><FONT COLOR="#000000">).getEnclosingDiv().innerHTML</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#800000">''</FONT><FONT COLOR="#000000">;   zen(</FONT><FONT COLOR="#800000">'selectFiles'</FONT><FONT COLOR="#000000">).refreshContents(); }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">fileSelected(</FONT><FONT COLOR="#ff00ff">files</FONT><FONT COLOR="#000000">) [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">holder </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">zen(</FONT><FONT COLOR="#800000">'holder'</FONT><FONT COLOR="#000000">).getEnclosingDiv();   </FONT><FONT COLOR="#008000">for </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">var </FONT><FONT COLOR="#000000">i </FONT><FONT COLOR="#000080">= 0</FONT><FONT COLOR="#000000">; i </FONT><FONT COLOR="#000080">< </FONT><FONT COLOR="#000000">files.length; i</FONT><FONT COLOR="#000080">++</FONT><FONT COLOR="#000000">) {        </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">file </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">files[i];

        </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">fileSize </FONT><FONT COLOR="#000080">= 0</FONT><FONT COLOR="#000000">;     </FONT><FONT COLOR="#008000">if </FONT><FONT COLOR="#000000">(file.size </FONT><FONT COLOR="#000080">> 1024  1024</FONT><FONT COLOR="#000000">)       fileSize </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">(Math.round(file.size </FONT><FONT COLOR="#000080"> 100 / </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">1024  1024</FONT><FONT COLOR="#000000">)) </FONT><FONT COLOR="#000080">/ 100</FONT><FONT COLOR="#000000">).toString() </FONT><FONT COLOR="#000080">+ </FONT><FONT COLOR="#000000">$$$Text(</FONT><FONT COLOR="#800000">'MB'</FONT><FONT COLOR="#000000">);     </FONT><FONT COLOR="#008000">else       </FONT><FONT COLOR="#000000">fileSize </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">(Math.round(file.size </FONT><FONT COLOR="#000080"> 100 / 1024</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">/ 100</FONT><FONT COLOR="#000000">).toString() </FONT><FONT COLOR="#000080">+ </FONT><FONT COLOR="#000000">$$$Text(</FONT><FONT COLOR="#800000">'KB'</FONT><FONT COLOR="#000000">);        </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">divInfo </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">document.createElement(</FONT><FONT COLOR="#800000">'div'</FONT><FONT COLOR="#000000">);     divInfo.innerHTML</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#000000">file.name</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#800000">' ('</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#000000">file.type</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#800000">') - '</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#000000">fileSize;     holder.appendChild(divInfo);

        </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">divProgN </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">document.createElement(</FONT><FONT COLOR="#800000">'div'</FONT><FONT COLOR="#000000">);     divProgN.id</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#800000">'progressNumber'</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#000000">i;     divProgN.innerHTML</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#800000">'%'</FONT><FONT COLOR="#000000">;     holder.appendChild(divProgN);

        </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">prog </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">document.createElement(</FONT><FONT COLOR="#800000">'progress'</FONT><FONT COLOR="#000000">);     prog.id</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#800000">'progressValue'</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#000000">i;     prog.max</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#800000">'100.0'</FONT><FONT COLOR="#000000">;     prog.value</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#800000">'0'</FONT><FONT COLOR="#000000">;     holder.appendChild(prog);

        fileQueue.push({i:i,file:file});   } }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">uploadFile() [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   </FONT><FONT COLOR="#008000">while </FONT><FONT COLOR="#000000">(fileQueue.length </FONT><FONT COLOR="#000080">> 0</FONT><FONT COLOR="#000000">) {     </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">item</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#000000">fileQueue.pop();     uploadFile(item.file,item.i);   } }

    </FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">onloadHandler() [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   </FONT><FONT COLOR="#008000">if </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">typeof </FONT><FONT COLOR="#000000">FileReader </FONT><FONT COLOR="#000080">== </FONT><FONT COLOR="#800000">"undefined"</FONT><FONT COLOR="#000000">) zenAlert($$$Text(</FONT><FONT COLOR="#800000">'Sorry, your browser does not support File API, so this demo will not work correctly'</FONT><FONT COLOR="#000000">));   fileQueue </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">new </FONT><FONT COLOR="#000000">Array();

      uploadFile </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#008080">function </FONT><FONT COLOR="#000000">(file, i) {     </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">xhr </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">new </FONT><FONT COLOR="#000000">XMLHttpRequest(), upload </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">xhr.upload, fd </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">new </FONT><FONT COLOR="#000000">FormData();          fd.append(</FONT><FONT COLOR="#800000">'fUpload'</FONT><FONT COLOR="#000000">, file);

        upload.addEventListener(</FONT><FONT COLOR="#800000">'progress'</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#008080">function </FONT><FONT COLOR="#000000">(evt) {       </FONT><FONT COLOR="#008000">if </FONT><FONT COLOR="#000000">(evt.lengthComputable) {         </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">percentComplete </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">Math.round(evt.loaded </FONT><FONT COLOR="#000080">* 100 / </FONT><FONT COLOR="#000000">evt.total);

            document.getElementById(</FONT><FONT COLOR="#800000">'progressNumber'</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#000000">i).innerHTML </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">percentComplete.toString() </FONT><FONT COLOR="#000080">+ </FONT><FONT COLOR="#800000">'%'</FONT><FONT COLOR="#000000">;         document.getElementById(</FONT><FONT COLOR="#800000">'progressValue'</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#000000">i).value </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">percentComplete;                }       </FONT><FONT COLOR="#008000">else </FONT><FONT COLOR="#000000">{         document.getElementById(</FONT><FONT COLOR="#800000">'progressNumber'</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#000000">i).innerHTML </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#000000">$$$Text(</FONT><FONT COLOR="#800000">'Cannot compute'</FONT><FONT COLOR="#000000">);       }            }, false);     upload.addEventListener(</FONT><FONT COLOR="#800000">'load'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">function </FONT><FONT COLOR="#000000">(ev) {       </FONT><FONT COLOR="#008080">var </FONT><FONT COLOR="#000000">c</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#000000">document.getElementById(</FONT><FONT COLOR="#800000">'progressNumber'</FONT><FONT COLOR="#000080">+</FONT><FONT COLOR="#000000">i);       c.className</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#800000">'ok'</FONT><FONT COLOR="#000000">;       c.innerHTML</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#800000">'OK'</FONT><FONT COLOR="#000000">;     }, false);     upload.addEventListener(</FONT><FONT COLOR="#800000">'error'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">function </FONT><FONT COLOR="#000000">(ev) {zenAlert($$$Text(</FONT><FONT COLOR="#800000">'An error occurred when trying to upload the file.'</FONT><FONT COLOR="#000000">));}, false);     upload.addEventListener(</FONT><FONT COLOR="#800000">'abort'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">function </FONT><FONT COLOR="#000000">(ev) {zenAlert($$$Text(</FONT><FONT COLOR="#800000">'The upload was canceled by the user or the browser dropped the connection.'</FONT><FONT COLOR="#000000">));}, false);     xhr.open(</FONT><FONT COLOR="#800000">'POST'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'upload.fileMany.cls'</FONT><FONT COLOR="#000000">);     xhr.setRequestHeader(</FONT><FONT COLOR="#800000">'Cache-Control'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#800000">'no-cache'</FONT><FONT COLOR="#000000">);     xhr.setRequestHeader(</FONT><FONT COLOR="#800000">'X-Requested-With'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#800000">'XMLHttpRequest'</FONT><FONT COLOR="#000000">);     xhr.send(fd);   }      dropZone</FONT><FONT COLOR="#000080">=</FONT><FONT COLOR="#000000">zen(</FONT><FONT COLOR="#800000">'dropZone'</FONT><FONT COLOR="#000000">).getEnclosingDiv();   dropZone.addEventListener(</FONT><FONT COLOR="#800000">'dragenter'</FONT><FONT COLOR="#000000">,  </FONT><FONT COLOR="#008080">function</FONT><FONT COLOR="#000000">(ev){     ev.stopPropagation();     ev.preventDefault();   }, false);   dropZone.addEventListener(</FONT><FONT COLOR="#800000">'dragleave'</FONT><FONT COLOR="#000000">,  </FONT><FONT COLOR="#008080">function</FONT><FONT COLOR="#000000">(ev){     ev.stopPropagation();     ev.preventDefault();     </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.style[</FONT><FONT COLOR="#800000">'backgroundColor'</FONT><FONT COLOR="#000000">] </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">'#FEFEFE'</FONT><FONT COLOR="#000000">;     </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.style[</FONT><FONT COLOR="#800000">'borderColor'</FONT><FONT COLOR="#000000">] </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">'#CCC'</FONT><FONT COLOR="#000000">;     </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.style[</FONT><FONT COLOR="#800000">'color'</FONT><FONT COLOR="#000000">] </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">'#CCC'</FONT><FONT COLOR="#000000">;   }, false);   dropZone.addEventListener(</FONT><FONT COLOR="#800000">'dragover'</FONT><FONT COLOR="#000000">,  </FONT><FONT COLOR="#008080">function</FONT><FONT COLOR="#000000">(ev){     ev.stopPropagation();     ev.preventDefault();     </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.style[</FONT><FONT COLOR="#800000">'backgroundColor'</FONT><FONT COLOR="#000000">] </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">'#F0FCF0'</FONT><FONT COLOR="#000000">;     </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.style[</FONT><FONT COLOR="#800000">'borderColor'</FONT><FONT COLOR="#000000">] </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">'#3DD13F'</FONT><FONT COLOR="#000000">;     </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.style[</FONT><FONT COLOR="#800000">'color'</FONT><FONT COLOR="#000000">] </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">'#3DD13F'</FONT><FONT COLOR="#000000">;   }, false);   dropZone.addEventListener(</FONT><FONT COLOR="#800000">'drop'</FONT><FONT COLOR="#000000">,  </FONT><FONT COLOR="#008080">function</FONT><FONT COLOR="#000000">(ev){   ev.stopPropagation();   ev.preventDefault();   </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.style[</FONT><FONT COLOR="#800000">'backgroundColor'</FONT><FONT COLOR="#000000">] </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">'#FEFEFE'</FONT><FONT COLOR="#000000">;   </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.style[</FONT><FONT COLOR="#800000">'borderColor'</FONT><FONT COLOR="#000000">] </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">'#CCC'</FONT><FONT COLOR="#000000">;   </FONT><FONT COLOR="#800000">this</FONT><FONT COLOR="#000000">.style[</FONT><FONT COLOR="#800000">'color'</FONT><FONT COLOR="#000000">] </FONT><FONT COLOR="#000080">= </FONT><FONT COLOR="#800000">'#CCC'</FONT><FONT COLOR="#000000">;   zenPage.fileSelected(ev.dataTransfer.files);   }, false); }

    </FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">%OnPreHTTP() </FONT><FONT COLOR="#000080">As %Boolean </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">ServerOnly </FONT><FONT COLOR="#000000">= 1 ] {   </FONT><FONT COLOR="#0000ff">#dim </FONT><FONT COLOR="#800000">%request </FONT><FONT COLOR="#0000ff">As </FONT><FONT COLOR="#008080">%CSP.Request   </FONT><FONT COLOR="#0000ff">#dim </FONT><FONT COLOR="#800000">stream </FONT><FONT COLOR="#0000ff">As </FONT><FONT COLOR="#008080">%CSP.BinaryStream</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">%request</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">GetMimeData</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"fUpload"</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">if $IsObject</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#800080">{          </FONT><FONT COLOR="#008000">#; here you do with the received file useful work          /*     set ^tmp("filename")=stream.FileName     set ^tmp("filesize")=stream.Size     */          </FONT><FONT COLOR="#0000ff">quit $$$NO   </FONT><FONT COLOR="#800080">}   </FONT><FONT COLOR="#0000ff">quit $$$YES </FONT><FONT COLOR="#000000">}

    }</FONT>

Of course you can do the same on CSP.
Vitaliy Serdtsev · Nov 10, 2017 go to post

See aside iFind.

I long ago did the tests, using Bible, at searching for of any substring.

  1. without an index
    <FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008000">Id</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008000">Para </FONT><FONT COLOR="#000080">from </FONT><FONT COLOR="#008000">BookPara </FONT><FONT COLOR="#000080">where </FONT><FONT COLOR="#008000">Para </FONT><FONT COLOR="#000000">like </FONT><FONT COLOR="#008080">'%огон%'</FONT>
  2. with index
    <FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008000">Id</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008000">Para </FONT><FONT COLOR="#000080">from </FONT><FONT COLOR="#008000">BookPara </FONT><FONT COLOR="#000080">where </FONT><FONT COLOR="#008000">id </FONT><FONT COLOR="#000000">%FIND </FONT><FONT COLOR="#808000">search_index</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">ParaStemmedI</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'огон'</FONT><FONT COLOR="#000000">,1)</FONT>
The number of found rowsPerformance (sec.)Global references
The result:
without an index2870.518151845
with index2870.0091006
The difference is obvious.
Vitaliy Serdtsev · Nov 10, 2017 go to post
  1. <html>
    <body>
    <script language="cache" runat="server">
     if %request.ContentType="multipart/form-data" {
      stream=%request.MimeData("oFile1",1)
      file=##class(%Stream.FileBinary).%New()
      file.Filename="c:\InterSystems\"_##class(%File).GetFilename(stream.FileName)
      file.CopyFromAndSave(stream)
     }
    </script>
    <br>
    <FORM NAME="oForm" ENCTYPE="multipart/form-data" METHOD="post">
    <INPUT TYPE="file" NAME="oFile1"/>
    <INPUT TYPE="submit" VALUE="Upload File">
    </FORM>
    </body>
    </html>
  2. <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1, user-scalable=no"/>
    

        <</FONT><FONT COLOR="#ff0000">title</FONT><FONT COLOR="#000000">>Uploading a file from the client to the server without reloading the page</</FONT><FONT COLOR="#ff0000">title</FONT><FONT COLOR="#000000">>

        <</FONT><FONT COLOR="#ff0000">script </FONT><FONT COLOR="#000080">type</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"text/javascript" </FONT><FONT COLOR="#000080">src</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"jquery.min.js"</FONT><FONT COLOR="#000000">></</FONT><FONT COLOR="#ff0000">script</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#ff0000">script </FONT><FONT COLOR="#000080">type</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"text/javascript" </FONT><FONT COLOR="#000080">src</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"js/vendor/jquery.ui.widget.js"</FONT><FONT COLOR="#000000">></</FONT><FONT COLOR="#ff0000">script</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#ff0000">script </FONT><FONT COLOR="#000080">type</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"text/javascript" </FONT><FONT COLOR="#000080">src</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"js/jquery.iframe-transport.js"</FONT><FONT COLOR="#000000">></</FONT><FONT COLOR="#ff0000">script</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#ff0000">script </FONT><FONT COLOR="#000080">type</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"text/javascript" </FONT><FONT COLOR="#000080">src</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"js/jquery.fileupload.js"</FONT><FONT COLOR="#000000">></</FONT><FONT COLOR="#ff0000">script</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#ff0000">script </FONT><FONT COLOR="#000080">type</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"text/javascript"</FONT><FONT COLOR="#000000">>     $(</FONT><FONT COLOR="#008080">function</FONT><FONT COLOR="#000000">(){       $(</FONT><FONT COLOR="#800000">'#fileupload'</FONT><FONT COLOR="#000000">).fileupload();     });        </</FONT><FONT COLOR="#ff0000">script</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#ff0000">script </FONT><FONT COLOR="#000080">language</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"cache" </FONT><FONT COLOR="#000080">runat</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"server"</FONT><FONT COLOR="#000000">>       </FONT><FONT COLOR="#0000ff">if </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">%request</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">IsDefinedMimeData</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"files[]"</FONT><FONT COLOR="#000000">,1) ) </FONT><FONT COLOR="#800080">{                  </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">%request</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">GetMimeData</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"files[]"</FONT><FONT COLOR="#000000">)                  </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">file</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Stream.FileBinary</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()         </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">file</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Filename</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"c:\InterSystems&quot;</FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">FileName         d </FONT><FONT COLOR="#800000">file</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">CopyFromAndSave</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">)       </FONT><FONT COLOR="#800080">}

        </FONT><FONT COLOR="#000000"></</FONT><FONT COLOR="#ff0000">script</FONT><FONT COLOR="#000000">>   </</FONT><FONT COLOR="#ff0000">head</FONT><FONT COLOR="#000000">>

      <</FONT><FONT COLOR="#ff0000">body</FONT><FONT COLOR="#000000">>     #(</FONT><FONT COLOR="#0000ff">$H</FONT><FONT COLOR="#000000">)#<</FONT><FONT COLOR="#ff0000">input </FONT><FONT COLOR="#000080">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"fileupload" </FONT><FONT COLOR="#000080">type</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"file" </FONT><FONT COLOR="#000080">name</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"files[]" </FONT><FONT COLOR="#000080">data-url</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"</FONT><FONT COLOR="#000000">#(</FONT><FONT COLOR="#800000">%request</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">PageName</FONT><FONT COLOR="#000000">)#</FONT><FONT COLOR="#800080">" </FONT><FONT COLOR="#000080">multiple data-sequential-uploads</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800080">"false"</FONT><FONT COLOR="#000000">>   </</FONT><FONT COLOR="#ff0000">body</FONT><FONT COLOR="#000000">> </</FONT><FONT COLOR="#ff0000">html</FONT><FONT COLOR="#000000">></FONT>

  3. <FONT COLOR="#000080">Class dc.fileuploadajax 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="#800000">title</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Uploading a file from the client to the server without reloading the page"</FONT><FONT COLOR="#000000">>   <</FONT><FONT COLOR="#000080">group </FONT><FONT COLOR="#800000">labelPosition</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"left"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">text </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Current date/time on the server:" </FONT><FONT COLOR="#800000">value</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"#(%this.%Eval($ZDT($H)))#"</FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">group</FONT><FONT COLOR="#000000">>   <</FONT><FONT COLOR="#000080">form </FONT><FONT COLOR="#800000">enctype</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"multipart/form-data" </FONT><FONT COLOR="#800000">target</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"upload_target" </FONT><FONT COLOR="#800000">labelPosition</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"left"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">text </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Name:" </FONT><FONT COLOR="#800000">name</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"proc"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">fileUpload </FONT><FONT COLOR="#800000">name</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"file" </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Select a file:"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">submit </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Upload"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">iframe </FONT><FONT COLOR="#800000">name</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"upload_target" </FONT><FONT COLOR="#800000">hidden</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"true"</FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">form</FONT><FONT COLOR="#000000">>   <</FONT><FONT COLOR="#000080">fieldSet </FONT><FONT COLOR="#800000">legend</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Information about a previously uploaded file" </FONT><FONT COLOR="#800000">labelPosition</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"left"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">text </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"proc" </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Name"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">text </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"fileSize" </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"File size"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">text </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"fileName" </FONT><FONT COLOR="#800000">label</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"File name"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Refresh" </FONT><FONT COLOR="#800000">onclick</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zenPage.GetFileInfo();"</FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">fieldSet</FONT><FONT COLOR="#000000">> </</FONT><FONT COLOR="#000080">page</FONT><FONT COLOR="#000000">> }

    </FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">%OnSubmit(</FONT><FONT COLOR="#ff00ff">pSubmit </FONT><FONT COLOR="#000080">As %ZEN.Submit</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">#dim </FONT><FONT COLOR="#800000">%session </FONT><FONT COLOR="#0000ff">As </FONT><FONT COLOR="#008080">%CSP.Session   </FONT><FONT COLOR="#0000ff">#dim </FONT><FONT COLOR="#800000">stream </FONT><FONT COLOR="#0000ff">As </FONT><FONT COLOR="#008080">%CSP.BinaryStream</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">pSubmit</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%GetStream</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"file"</FONT><FONT COLOR="#000000">)

      </FONT><FONT COLOR="#0000ff">if $IsObject</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">%session</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Data</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"fileSize"</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Size     set </FONT><FONT COLOR="#800000">%session</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Data</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"fileName"</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#800000">stream</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">FileName   </FONT><FONT COLOR="#800080">}   </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">%session</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Data</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"proc"</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#800000">pSubmit</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%GetValue</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"proc"</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">quit $$$OK </FONT><FONT COLOR="#000000">}

    </FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">GetFileInfo() [ </FONT><FONT COLOR="#000080">ZenMethod </FONT><FONT COLOR="#000000">] {   </FONT><FONT COLOR="#800080">&js<   </FONT><FONT COLOR="#000000">zenSetProp(</FONT><FONT COLOR="#800000">'proc'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'value'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">#(</FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">QuoteJS</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">%session</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Data</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"proc"</FONT><FONT COLOR="#000000">))</FONT><FONT COLOR="#800000">)#</FONT><FONT COLOR="#000000">);   zenSetProp(</FONT><FONT COLOR="#800000">'fileSize'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'value'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">#(</FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">QuoteJS</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">%session</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Data</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"fileSize"</FONT><FONT COLOR="#000000">))</FONT><FONT COLOR="#800000">)#</FONT><FONT COLOR="#000000">);   zenSetProp(</FONT><FONT COLOR="#800000">'fileName'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'value'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">#(</FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">QuoteJS</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">%session</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Data</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"fileName"</FONT><FONT COLOR="#000000">))</FONT><FONT COLOR="#800000">)#</FONT><FONT COLOR="#000000">);   </FONT><FONT COLOR="#800080">> </FONT><FONT COLOR="#000000">} }</FONT>

If you want, I can give ZEN-examples of asynchronous uploading of immediately several files using the File API, but this will only work in new browsers.
Vitaliy Serdtsev · Nov 9, 2017 go to post

The following corrected code works for me:

<FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">WriteNodes(</FONT><FONT COLOR="#ff00ff">myfile </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">)
{
  </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">status</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%XML.TextReader</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">ParseFile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">myfile</FONT><FONT COLOR="#000000">,.</FONT><FONT COLOR="#800000">textreader</FONT><FONT COLOR="#000000">)
  </FONT><FONT COLOR="#0000ff">if $$$ISERR</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">status</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#800080">{</FONT><FONT COLOR="#0000ff">do $System</FONT><FONT COLOR="#008080">.Status</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">status</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#0000ff">quit</FONT><FONT COLOR="#800080">}

  </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Stream.FileCharacter</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Filename</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"C:\IT\50_TestIn\warddata1.txt"   //check status   //iterate through document, node by node   </FONT><FONT COLOR="#0000ff">while </FONT><FONT COLOR="#800000">textreader</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Read</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">Do </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Write</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Node " </FONT><FONT COLOR="#000000"> </FONT><FONT COLOR="#800000">textreader</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">seq </FONT><FONT COLOR="#000000"> </FONT><FONT COLOR="#008000">" is a(n) "</FONT><FONT COLOR="#000000">)     </FONT><FONT COLOR="#0000ff">Do </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Write</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">textreader</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">NodeType </FONT><FONT COLOR="#000000"> </FONT><FONT COLOR="#008000">" "</FONT><FONT COLOR="#000000">)     </FONT><FONT COLOR="#0000ff">If </FONT><FONT COLOR="#800000">textreader</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Name</FONT><FONT COLOR="#000000">'=</FONT><FONT COLOR="#008000">""     </FONT><FONT COLOR="#800080">{       </FONT><FONT COLOR="#0000ff">Do </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Write</FONT><FONT COLOR="#000000">( </FONT><FONT COLOR="#008000">"named: "</FONT><FONT COLOR="#000000"> </FONT><FONT COLOR="#800000">textreader</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Name</FONT><FONT COLOR="#000000">)     </FONT><FONT COLOR="#800080">}     </FONT><FONT COLOR="#0000ff">Else     </FONT><FONT COLOR="#800080">{       </FONT><FONT COLOR="#0000ff">Do </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Write</FONT><FONT COLOR="#000000">( </FONT><FONT COLOR="#008000">"and has no name"</FONT><FONT COLOR="#000000">)     </FONT><FONT COLOR="#800080">}     </FONT><FONT COLOR="#0000ff">Do </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Write</FONT><FONT COLOR="#000000">( </FONT><FONT COLOR="#008000">" path: " </FONT><FONT COLOR="#000000"> </FONT><FONT COLOR="#800000">textreader</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Path</FONT><FONT COLOR="#000000">)     </FONT><FONT COLOR="#0000ff">If </FONT><FONT COLOR="#800000">textreader</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Value</FONT><FONT COLOR="#000000">'=</FONT><FONT COLOR="#008000">""      </FONT><FONT COLOR="#800080">{       </FONT><FONT COLOR="#0000ff">Do </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Write</FONT><FONT COLOR="#000000">( </FONT><FONT COLOR="#008000">" value: " </FONT><FONT COLOR="#000000"> </FONT><FONT COLOR="#800000">textreader</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Value</FONT><FONT COLOR="#000000">)     </FONT><FONT COLOR="#800080">}     </FONT><FONT COLOR="#0000ff">Do </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">WriteLine</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#800080">}

  </FONT><FONT COLOR="#0000ff">Do </FONT><FONT COLOR="#800000">ptemp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Save</FONT><FONT COLOR="#000000">() }</FONT>

Vitaliy Serdtsev · Nov 9, 2017 go to post
set ptemp=##class(%GlobalCharacterStream).%New()set ptemp=##class(%Stream.FileCharacter).%New()
set ptemp.Filename="C:\IT\50_TestIn\warddata1.txt"set adapter ##class(%File).%New("C:\IT\50_TestIn\warddata1.txt")
set status adapter.Write(ptemp)set status ptemp.%Save()