Promotic
WikipediaLinkedInYoutubeTwitterFacebook

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 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])
Calling:
value = oTView.SaveToHtm(sSrcHtm, sDstHtm, sParams)
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 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 contents of the HTML page.
- string in 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 KeyVal format, for example "mode:graph;view:dlg;".
"mode:xxx;" (optional) - Specifies which page is used for displaying the data of the trends 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 graphic trend viewer (PmgTrendViewer) in saved HTML page. The HTML page contains its own object (PmgTrendViewer).
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 allows 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 keyword title from the template (sSrcHtm) will be replaced by the string yyy.

Example: text_title:BoilerPlant 5;

text_note1 - Value of the keyword note1 from the template (sSrcHst) will be replaced by the string yyy.
text_note2 - Value of the keyword note2 from the template (sSrcHst) will be replaced by the string yyy.
text_codeinit - Value of the keyword codeinit from the template (sSrcHst) will be replaced by the string yyy. The yyy string 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 key word codeinit from the template. See the description of the sParams parameter, the codeinit value.
Return values:
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 parameter sDstHtm is set to "return:"
See also:
Example1:
Creates an graphic HTML page for printing in memory. Then it is possible to print the created HTML page using the default OS Windows 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 by 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 subtics between the main tics of the value scale. The created HTML page is displayed by 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 parameter "file:"
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.12 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice