Syntax
( * internal call of method of the current function block *)
THIS.method-name();|method-name();
THIS.method-name|method-name
(input_1:=x1,input_2:=x2,...,input_n:=xn,
output_1=>y1,output_2=>y2,...,output_n=>yn);
( * internal call of a method of the base function block from within a derived function block *)
SUPER.method-name();
SUPER.method-name
(input_1:=x1,input_2:=x2,...,input_n:=xn,
output_1=>y1,output_2=>y2,...,output_n=>yn)
( * external call of a method *)
instance-name.method-name();
instance-name.method-name
(input_1:=x1,input_2:=x2,...,input_n:=xn,
output_1=>y1,output_2=>y2,...,output_n=>yn);
Meaning
|
formal call of the →method without or with a parameter list The method is called by the name of the method method-name. The specification in front of this name determines in which context the method is called:
THIS. – This calls a method of the same language construct. As an alternative, it is also possible to omit THIS. here. Example: THIS.UP5(); or UP5(); – This calls the method UP5 e.g. within the method UP. Both methods are declared in the same →function block or in the base function block
(if the function block containing the call of the method is a derived function block; see details on the keyword
EXTENDS
under "
Declaration of a function block in ST
").
SUPER. – This calls a method of the base function block from within a derived function block. Example: SUPER.UP5(); – This calls the method UP5 of the base function block. The method is called within a function block that has been
derived from a base function block by using the keyword
EXTENDS
.
instance-name. – This calls a method of an →instance. Example: Inst1.UP5(); – This calls the method UP5 of the instance Inst1.
No check of recursions
Recursions for →functions and →methods are not forbidden or checked by
logi.CAD 3
. Nevertheless, do not call a function/method from within itself and avoid 2 (or more) functions/methods calling each other (= mutual recursion) within your application.
Mind that recursions of functions/methods might cause unexpected results when your application is executed. For example, the application might be executed in an infinite loop and/or the →runtime system
might not respond anymore.
The possibilities for the parameter list are analogous to the
call of a function
.
This parameter list of a formal →call may contain the following elements:
→assignments to →input variables (incl. to input EN) The expression on the right side of the assignment operator ":=" in the assignments to input variables may be one of the constructs as listed under Assignment.
assignments to →in-out variables The expression on the right side of the assignment operator ":=" in the assignments to in-out variables may be just a construct which might be on the left side of the assignment operator ":=" as well.
assignments of →output variables (incl. to output ENO) The expression on the right side of the assignment operator "=>" in the assignments of output variables may be a declared →variable (e.g. result) of a fitting →data type.
As alternatives, you can use the following variants for the call:
non-formal call
The parameter list must contain the same number of input variables, in exactly the same order and of fitting data types as given in the declaration
, except the execution control parameters EN and ENO.
Example:
Inst1.UP3 (10,20,T#3ms);
– This non-formal call is equivalent to the formal call:
Inst1.UP3 (EN := TRUE, IN1:=10, IN2 := 20, T1 := T#3ms, OUT => result);
incomplete parameter list of formal call You can omit input variables and output variables within the parameter list. Omitted input variables get the default →initial value.
As previously mentioned, this is
analogous to the call of a function (s
ee the examples there.
The FAQ article "When to use a formal call? When to use a non-formal call?" lists a table when to use formal call vs. non-formal call.
|
An example for an internal call of a method with a parameter list but without
EN
/
ENO
is listed under "
Declaration of a method
".
An example for the different calls of methods (using THIS., SUPER. and instance-name.) is listed under "Declaration of a function block in ST".