Semantic Check of Scripts
The semantic check of Control scripts in WinCC OA goes through the following issues (check without guarantee of completeness) :
-
Are variables known.
-
Are variables accessible (private).
-
Are dollar parameters known.
-
Are functions known.
-
Are functions accessible (private).
-
Number of arguments.
-
Is a variable declaration of a already known variable is not accessible (for example a local variable has the same name as a global variable).
-
Can a function not be accessed through an external in function call written in C++ .
-
Does an empty assignment after "while" or "for" assignments (for example "while (foo) ; bar();" exist.
-
An assignment as condition in "if", "do", "while" or "for" is accepted. For example, "if (i = 2) foo();" "if ( (i = 2) ) foo();".
-
A value in an assignment, for example, dpConnect() = 3;
You can use the semantic check as follows:
WCCOActrl -syntax -proj [projName] [scriptName]
If you, for example, want to check a script called SynCheck.ctl in the project Proj_3.10call the Control manager as follows:
WCCOActrl -syntax -proj Proj_3.10 SynCheck.ctl
All errors (PRIO_SEVERE) and all warnings (PRIO_WARNING) will be shown in the Log Viewer. The output of the semantic check could look, for example, as follows:
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, WARNING, 12/ctrl, External declaration of function "dpConnect" shadows definition at a.ctl:10.
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, SEVERE, 73, Variable not defined, a.ctl Line: 25, undefined_var
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, SEVERE, 76, Invalid argument in function, a.ctl Line: 28, private_var defined in b.ctl is private in this context.
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, SEVERE, 17/ctrl, Cannot find dollar parameter $I. Location: a.ctl Line: 32
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, SEVERE, 72, Function not defined, a.ctl Line: 35, undefined_func
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, SEVERE, 76, Invalid argument in function, a.ctl Line: 38, private_func, private_func defined in b.ctl is private in this context.
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, SEVERE, 75, Argument missing in function, a.ctl Line: 41, number_of_arg, a2
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, WARNING, 11/ctrl, Declaration of "g" shadows old declaration at "a.ctl Line: 3". Location: a.ctl Line: 44
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, WARNING, 13/ctrl, Empty statement found. Location: a.ctl Line: 51
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, WARNING, 14/ctrl, Assignment used in a condition. Location: a.ctl Line: 55
WCCOActrl (0), 2010.11.03 10:50:23.454, CTRL, SEVERE, 78, Assignment to this expression impossible, a.ctl Line: 58
Limitations:
-
A Control manager cannot check scripts running in a User interface.
-
The keyword #uses has to be used to declare all necessary libraries.
-
The functions addGlobal and removeGlobal are not evaluated. If you do not declare global variables as "global" but add a variable at run time using the function addGlobal, an error will be shown.
-
Shapes will not be evaluated.
-
An error will be shown if a Control library tries to access variables that were declared in a panel.