Script

<< Click to Display Table of Contents >>

Navigation:  Delphi HTML Report Library > Tables >

Script

Script section can be used for complex data processing and generating.
For detailed description of script syntax and available functions please refer to the HTML Scripter documentation.

Script is executed right after SQL section (if present) and before any other formatting is applied.

Script has the following predefined variables:

<all variables defined by Report.AddVariable and generated by datapackets>

datapacket: THtXMlNode - current datapacket

rowdata : THtXMLNode - current rowdata node

fields - current fields node

report : THtReport - report object

context: THtXMLNode - report context

adapter : THtSQLAdapter - current SQL adapter

masterdata: THtXMLNode - current master row for detail packet.

 

Example of generating data using script:

<DATAPACKET>
 <METADATA>
  <FIELDS>
   <FIELD name="CUSTNO"/>
   <FIELD name="ADDR1" />
   <FIELD name="COMPANY" />
   <FIELD name="CITY" />
   <FIELD name="STATE" />
   <FIELD name="PHONE" />
   <FIELD name="CONTACT" />
  </FIELDS>
  <SCRIPT>
   for i:= 1 to 100 do begin
     R := RowData.Add('R');
     R.Attr['COMPANY'] := 'Company';
   end;
  </SCRIPT>
 </METADATA>
 <ROWDATA/>
</DATAPACKET>

 

Example of processing data using script:

 

<DATAPACKET>
 <METADATA>
  <FIELDS>
   <FIELD name="CUSTNO"/>
   <FIELD name="ADDR1" />
   <FIELD name="COMPANY" />
   <FIELD name="CITY" />
   <FIELD name="STATE" />
   <FIELD name="PHONE" />
   <FIELD name="CONTACT" />
  </FIELDS>
  <SQL>
   select * from customer
  </SQL>
  <SCRIPT>
  for i:= 0 to Rowdata.Count - 1 do
    RowData.Nodes[i].Attr['CITY'] := 'test';
  </SCRIPT>
 </METADATA>
</DATAPACKET>