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();
}

 

Date added:
Last revised:
Hits:
6.159
Rating:
Rating: 0.0. 0 vote(s). No rating done at all.
Your vote was '' (0 of 5) You are an anonymous user.
You may log on to do personalized votings
Click the rating bar to rate this item Please log on to do ratings
  • Notification

    FE user cannot be identified! (1403201096)

  • Information

    Not already rated (1403203414)

Tags:
Engineering, Programming / Scripting, WinCC Open Architecture, HMI