pvAddSeparator()
Adds a separator between two options of the context menu in the project view. It is not possible to set a separator behind the last menu option or before the first menu option. Also it is possible to set only one separator between two options. If this function is used in the script between the same options multiple times, anyhow, only one separator will be shown in the context menu.
This function is for use in the projectView.ctl file only (wincc_oa_path/[Version]/scripts/gedi/projectView.ctl). It is not advised to overwrite the original file, because this is effective WinCC OA wide. Instead, copy the original file to your project directory and make changes there. Thus the changes will only have an effect project-wide.
Synopsis
int pvAddSeparator(string parent = "");
Parameters
Parameter | Description |
---|---|
parent | Defines the submenu. See also pvConnect() options mapping. |
Return value
Number of the separator position.
Error
Missing context menu options.
Description
Adds a separator between two options of the context menu in the project view. It is not possible to set a separator behind the last menu option or before the first menu option. Also it is possible to set only one separator between two options. If this function is used in the script between the same options multiple times, anyhow, only one separator will be shown in the context menu.
EXAMPLE
The following example demonstrates how to load the interface for the CVS version control system into the project view (see also wincc_oa_path/Scripts/Gedi/projectView.ctl).
#uses "CtrlPv2Admin"
int versionColumn, statusColumn, tagdateColumn;
string tmpFile;
main()
{
string configFile = getPath(CONFIG_REL_PATH, "config");
string vcs;
paCfgReadValue(configFile, "ui", "versionControl", vcs);
paCfgReadValue(configFile, "ui", "versionControlDiff", diffProgram);
if ( vcs != "CVS" ) return;
pvConnect("CVS_log", "CVS log");
pvAddSeparator();
pvConnect("CVS_status", "CVS status");
pvConnect("CVS_update", "CVS update", "cvs_update");
versionColumn = pvAddColumn("Version");
statusColumn = pvAddColumn("Status&q
tagdateColumn = pvAddColumn("Tag/Date");
reload();
}
//----------------------------------------------------------------------
void reload()
{
CVS_entries(getPath(PANELS_REL_PATH));
CVS_entries(getPath(SCRIPTS_REL_PATH));
CVS_entries(getPath(LIBS_
CVS_entries(getPath(PICTURES_REL_PATH));
CVS_entries(getPath(COLORDB_REL_PATH));
}
//----------------------------------------------------------------------
setTmpNam()
{
tmpFile = tmpnam();
}
//----------------------------------------------------------------------
CVS_log(string fileName)
{
setTmpNam();
CVS_command("log -N", fileName);
showResult(fileName);
}
//----------------------------------------------------------------------
CVS_update(string fileName)
{
setTmpNam();
CVS_command("update", fileName);
showResult(fileName);
CVS_status(fileName);
}
//----------------------------------------------------------------------
CVS_status(string fileName)
{
bool isDir = isDirectory(fileName);
setTmpNam();
CVS_command("status -l", fileName); // non recursive as we only get filenames without path
file fd = fopen(tmpFile, "r");
string line, currentFile, version, status;
int pos;
bool gotFile = false;
while ( ! feof(fd) && (fgets(line, 1000, fd) > 0) )
{
if ( !gotFile )
{
if ( line[0] == '?' ) // file not in CVS
{
currentFile = baseName(substr(line, 2));
pvSetItemText(fileName + (isDir ? ("/" + currentFile) : ""),
statusColumn, "not in CVS");
continue;
}
pos = strpos(line, "File: ");
if ( pos != 0 ) continue;
gotFile = true;
sscanf(line, "File: %s", currentFile);
pos = strpos(line, "Status:");
status = substr(line, pos + strlen("Status:"));
pvSetItemText(fileName + (isDir ? ("/" + currentFile) : ""),
statusColumn, status);
}
pos = strpos(line, "Working revision:");
if ( pos == -1 ) continue;
sscanf(substr(line, pos+strlen("Working revision:")), "%s", version);
if ( version == "No" ) // No entry for ...
{
pvSetItemText(fileName + (isDir ? ("/" + currentFile) : ""),
statusColumn, "not in CVS");
}
else
{
pvSetItemText(fileName + (isDir ? ("/" + currentFile) : ""),
versionColumn, version);
gotFile = false;
}
}
fclose(fd);
remove(tmpFile);
if ( isDir ) // recursion
{
dyn_string files = getFileNamesRev(fileName, "CVS", FILTER_DIRS);
for (int i = 1; i <= dynlen(files); i++)
if ( (files[i] != ".") && (files[i] != "..") )
CVS_status(fileName + "/" + files[i]);
}
Availability
UI