LoadCfg - method of object TrendsView

Reading configuration data of viewer.

The configuration data are created in the XML format either by calling the SaveCfg or GetCfg method or 'manually', for example in the text editor.

LoadCfg(sCfg As String, nStyle As Long) As Boolean
b = oTView.LoadCfg(sCfg, nStyle)
sCfg(String) Source of the read configuration data.
"" - file on the server in the trend configuration folder (see the configurator "Path to configuration groups"), e.g. "".

Caution! The important fact is that this reference to the configuration file is valid for local application on the server and also for the client in the Web application. Therefore it is possible to use the same way of reading the configuration file, regardles if the application is local or Web. In the local application the file is read directly as file: and in the Web application as http:.

"file:" - Disk file, e.g. "file:c:/". See Example2.
"string:" - The parameter contains the configuration data themselves - a string in the XML format. The configuration is read even if the string: is omited at the beginning of the parameter, but it is recommended to use the string:.
"http:" - HTTP address, for example "http://computer/address/" must be entered in the parameter. See Example3.
"input:" - Selection from a list.

In the list there are filenames of configurations saved in the folder defined by #cfg:. (e.g. input:#cfg:).

In the Web client the configuration files saved locally in Web browser temporary storage by the SaveCfg method are also added to the list.

If the configuration server has been defined (using the AddServer method with sPurpose="cfg") parameter, then the configuration groups from this server are also included in this list. If the viewer is running in the Web panel, then additional configuration groups are added into the list from the Web panel server.

nStyle(Long) Specifies how the data have to be read into the viewer. The viewer properties are always overwritten. The parameter specifies how to read the tvTrend objects in case the viewer has already created some tvTrend objects (i.e. it views some graphs) before calling the method.
6 - In the viewer existing tvTrend objects are overwritten by the configuration data. If they don't exist, then new ones are created and filled up.
10 - Existing tvTrend objects are kept. New tvTrend objects are created and added.
11 - Existing tvTrend objects are removed. Then new tvTrend objects are created and added.
27 - If the tvTrend objects already exist in the viewer, then at first the window with the question whether to Remove the viewer content first (i.e. all trends), is displayed. Then new tvTrend objects are created and added.
Return Values:
true - successful loading
false - failed loading

The configuration data are represented by viewer text data using the XML language syntax, if saved to disk, then it is necessary to use a target file with the extension *.tg (the *.tg extension is known by the Promotic system thus able to work with the data stored in such files).

If the configuration data contains tvTrend objects with the data specifying a connection to the data sources - trend servers, then in the runtime mode of the viewer the trend objects are connected to the data sources (to servers) after reading.
Every calling the method sets the properties LastCfgSrc, LastCfgTitle. A user name of the configuration group is set in the LastCfgTitle property. The line with the user name isn't created automatically with creation of the configuration file by calling the SaveCfg method, it is necessary to add a line with this user configurable name into the content of the configuration file manually, see the description of the LastCfgTitle property.
Reading the configuration from the server file. Before the method is called, the existing tvTrend objects are deleted and the the configuration is read from the server file.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Acx;
if (oTView.LoadCfg("", 11))
  //.. configuration has been read
Reading the configuration from the disk file. Before calling the method existing tvTrend objects are removed, the configuration from the file is read afterwards.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Acx;
if (oTView.LoadCfg("file:c:/", 11))
  //.. configuration has been read
Reading the configuration from HTTP address. The trend viewer displays the trends from PROMOTIC application AP1. This trend viewer is contained in another PROMOTIC application panel or in a Web panel displayed in the Internet Explorer. It is necessary to load the configuration saved in a configuration file for example "". Let´s suppose that this file offers the application AP1 (this application is located on a network computer named "computerAP1") into the Web using the PmWebDir object (Web component identifier of this object is "dir3") at HTTP address for example "http://computerAP1/dir3/". Then the configuration can be loaded into the viewer:
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Acx;
if (oTView.LoadCfg("http://computerAP1/dir3/", 11))
  //.. configuration has been read
PROMOTIC 8.3.30 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