paCfgInsertValue()
The function adds a key (Config entry) /value (value of the config entry) pair to a specified section of the config file. You can also add the entry/value pair before or after the first or last search key (the search key is a specified config entry), before the first value (see the parameter table below).
Synopsis
int paCfgInsertValue(string filename, string section,string key, <type>
value [,string host] );
int paCfgInsertValue( string filename, string section, int op, string
searchKey,dyn_string keys, dyn_<type> values [,string host]
);
Parameter
Parameter | Description |
---|---|
filename | The file name of the config file e.g. "config" or "config.level". The name must be specified with an absolute path! |
section | The section of the config file e.g. "general". |
op | Where the entry should be added. BEFORE_FIRST_KEY(1), BEFORE_LAST_KEY(2), AFTER_LAST_KEY(3), AFTER_FIRST_KEY(4), BEFORE_FIRST_VALUE(5), AFTER_LAST_VALUE(6) |
searchKey | The search key after which the entry/value pair will be added to the config file. |
key | The config entry that will be added to the config file, for example "langs". |
value(s) |
The value that will be added to the config file, for example, "en_US.iso88591". Note: If you want to add several values to a key in one row you have to use the keyword "NOQUOTE:", so that the entry won't be automatically ended with a quotation mark ". The quotation marks can be added by using \". Example: paCfgInsertValue("myPath", "mySection", "myKey", "NOQUOTE:\"myValue\" 100 20"); Result: myKey = "myValue" 100 20 |
host | If an host entry has been defined, it will be written to the file with the entry. It will be placed before the entry in parenthesis, for example, (eiwrk028) config entry |
Return value
In case of errors, the function returns -1 otherwise, 0.
Error
Missing or wrong arguments
Description
The function adds a key (Config entry) /value (value of the config entry) pair to a specified section of the config file.
Example
You have to include the CtrlPv2Admin DLL into the general part of the code (to be able to use the paCfgInsertValue function) as follows: #uses "CtrlPv2Admin"
The following example adds the config entry "langs" to the [general] section of the config file (of the project Myproj).
main()
{
int val;
string filename = "c:/WinCC_OA_Proj/MyProj/config/config";
string section = "general";
val = paCfgInsertValue(filename,section,
"langs","en_US.iso88591");
/* Adds the entry "langs" containing the value "en_US.iso88591"
to the
"general" section of the config file (of the project
MyProj*/
}
Note that the maximum number of characters in a line of the configuration file is restricted to 511 characters (see also Configuration file).
Example
The following example adds the entry LoadCtrlLibs with the value mp.ctl to the Ctrl section of the config.level file.
main()
{
int val;
string filename = "C:/Siemens/Automation/WinCC_OA/3.10/config/config.level";
string section = "Ctrl";
val = paCfgInsertValue(filename,section,
"LoadCtrlLibs","mp.ctl");
/* Adds the LoadCtrlLibs entry with the value mp.ctl to the Ctrl
section of the config.level file*/
}
Assignment
Project administration functions
Availability
CTRL