How to access methods of shapes placed in another module
There is no problem if you want to access a property of a specific shape in another panel or module. You can do it as described in Online Help:
setValue("moduleName.panelName:shapeName","property","value");
main()
{
string sColor;
setValue("ModuleEllipse.PanelEllipse:MyEllipse","foreCol","Red"); getValue("ModuleEllipse.PanelEllipse:MyEllipse","backCol", sColor);
}
But if you want to access a method of a shape in another panel or module you cannot use the syntax above. You have to access the method of the shape with the help of the CTRL - function “invokeMethode()” or by using the “shape” data type.
Example:
User wants to call the method selectedItems() for the a tree widget “TREE1”, which is placed in panel “PanelViews” in a module named “ModuleBase”.
If only getValue() function is used:
main()
{
dyn_string dsItems;
getValue("ModuleBase.PanelViews:TREE1","selectedItems",dsItems );
}
WinCC OA UI throws following error message in the Log Viewer:
Object "TREE1" of type "TREE" does not know the attribute "selectedItems" for "getValue()"
Solution: Use of “invokeMethode” or “shape” data type:
main()
{
dyn_string dsItems;
invokeMethod("ModuleBase.PanelViews:TREE1", " selectedItems ", dsItems);
// OR
shape s = getShape("ModuleBase. PanelViews:TREE1");
dsItems = s.selectedItems();
}