pvSetItemText()
Sets an item text for a file in a specific column.
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
pvSetItemText(stringfileName,intcolumn,stringtext);
Parameters
Parameter | Description |
---|---|
fileName | Absolute file name, for example, panel name or script name. |
column | The number of the column that was created using pvAddColumn(). |
text | Content of the file. |
Return value
In case of errors, the function returns -1 otherwise, 0.
Error
Missing or wrong arguments
Description
Sets an item text for a file in a specific column.
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");
tagdateColumn = pvAddColumn("Tag/Date");
reload();
}
//----------------------------------------------------------------------
void reload()
{
CVS_entries(getPath(PANELS_REL_PATH));
CVS_entries(getPath(SCRIPTS_REL_PATH));
CVS_entries(getPath(LIBS_REL_PATH));
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