Promotic

SaveToHtm - method of the PmgTrendViewer object

Description:
The method reads the HTML file specified in the sSrcHtm parameter and modifies it by its own data exported into a text string and then creates the output HTML page that is then saved according to setting the sDstHtm parameter.
Such created HTML page can be in the graph or table form and it can be used, for example, for printing (see Example1).
Syntax:
Variant SaveToHtm(String sSrcHtm, String sDstHtm, String sParams, [String sParText])
Parameters:
sSrcHtm(String) Entering an empty string "" means that the model is generated by the PROMOTIC system.
sDstHtm(String) Location for saving the HTML page. It is either:
- string in the variable (String) - In this case the parameter is of the input/output type (the input is "string:") and after calling the method it contains the content of the HTML page.
- string in the variable (String) - where "return:" is the keyword, then the method returns the content of the HTML page. (The method with this parameter is functional also in JavaScript panels.)

macro expression cannot be used for input, but the EvalMacro method can be called.
sParams(String) Additional parameters that define the way of creating the destination file. Entries are in the KeyVal format, for example "mode:graph;view:dlg;".
"mode:xxx;" (optional) - Specifies which page is used for displaying the data of the trend viewer
table (default) - page in the table form
graph - page in the graph form of 2-dimensional graph
"graphcfg:xxx;" (optional) - Specifies what setting is used for the trend viewer in graphic form (the PmgTrendViewer object) in saved HTML page.
default (default) - All settings of the viewer in the saved HTML page will be default (except for time from-to).
copy - All settings of the viewer in the saved HTML page will be taken from the viewer, that was called the SaveToHtm method.
"view:xxx;" (optional) - Specifies whether and how the generated page has to be displayed
no (default) - is not displayed
dlg - generated page is displayed in the window with preset size
"text_xxx:yyy;" (optional) - Template (referred in the sSrcHtm parameter) contains several predefined keywords that allow to enter the designer text, which appears in the final page (referred in the sDstHtm parameter) instead of the keyword, see the description of values.
text_title - Value of the title keyword from the template (sSrcHtm) will be replaced by the string yyy.
Example: text_title:BoilerPlant 5;
text_note1 - Value of the note1 keyword from the template (sSrcHst) will be replaced by the string yyy.
text_note2 - Value of the note2 keyword from the template (sSrcHst) will be replaced by the string yyy.
text_codeinit - Value of the codeinit keyword from the template (sSrcHst) will be replaced by the string yyy.
The string yyy is an initialization code in the JavaScript language that is run during reading the page.
If a character ; (semicolon) occurs in the yyy string, then it is necessary to set text_codeinit:$Par:0; and the initialization code itself has to be set in the sParText parameter, see Example3. The oT reference used in the example is the reference to the PmgTrendViewer trends viewer and his name must be kept.
text_userYY - Except the predefined keywords it is possible to edit the copy of the template (copied from the original template from the PROMOTIC Web folder, see the description of the sSrcHst parameter) and to add next keywords in it and to define the string for replacement in this parameter. For example, if there is the userkey keyword in the HTML template, then the parameter is:
text_userkey:text for displaying;
sParText[optional] (String) Text for replacing the codeinit keyword from the template. See the description of the sParams parameter, the codeinit value.
Return value:
true - saving proceeded successfully (not valid if parameter sDstHtm = "return:")
false - Otherwise (not valid if parameter sDstHtm = "return:")
HTMLstring - Returns the html page content if sDstHtm parameter is set to "return:"
Note:
This method is also functional in Web panels.
See also:
Example1:
Creates an graphic HTML page for printing in the memory. Then it is possible to print the created HTML page using the default Windows OS printer and set the dimensions of the page.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Items("../TrendView");
var sHtml = oTView.SaveToHtm("", "return;", "mode:graph;");
if (sHtml != "")
{
Pm.PrintHtmlPage(sHtml, "sourcetype:textstring;printer:default;width:700px;height:930px;");
}
Example2:
Creates the graph HTML page for printing. Keywords title, note1 and note2 are successively replaced by the strings "Factory station", "Ironware district" and "Page created by John Weiss". The created HTML page is displayed in the Web browser and ready, for example, for printing.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Items("../TrendView");
var sHtml = oTView.SaveToHtm("", "return;", "mode:graph;text_title:Factory station;text_note1:Ironware district;text_note2:Page created by John Weiss;");
if (sHtml != "")
{
Pm.PrintHtmlPage(sHtml, "sourcetype:textstring;printer:default;width:700px;height:930px;");
}
Example3:
Creates the graphic HTML page for printing. The keyword codeinit from the HTML template is replaced by the string "oT.ScaleValue.MinorTicksNum=4; oT.Draw();". This resets the number of minor ticks between the main tics of the value scale. The created HTML page is displayed in the Web browser and ready, for example, for printing.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Items("../TrendView");
var sParCode = "oT.ScaleValue.MinorTicksNum=4; oT.Draw();";
oTView.SaveToHtm("", "return;", "mode:graph;view:dlg;text_codeinit:$Par:0;", sParCode);

History:
Pm9.00.00: Discontinued values in sSrcHtm and now only the TrPrintGraph2.htm template is used
Pm8.00.09: sSrcHtm="ver:1" print tepmates versions introduced (TrPrintGraph2.htm)
Pm9.00.09: sDstHtm removed the file: parameter
Pm8.01.02: The method did not work correctly when the trend was filled by the AddPoints method. The patch has also been included into the version Pm8.0.13.
Pm8.00.08: Fixed bug: This method is used for printing the trends and in some cases did not print the trends correctly - different colors, limits, etc.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.