Calls in ST

The following language elements can be called in ST:

Order for calling a language element

If you are calling one of these language elements but there are different language elements with the same name, the following order is applied:

  1. call of the method

  2. call of the function block instance – only if there is no method with the same name

  3. call of the function – only if there is no method and no function block instance with the same name

Here an explanation of this order using the example 1 where the following 3 language elements are declared:

  • one function block instance named Element1 (within the section VAR...END)

  • one method named Element1

  • one function named Element1

Due to the order for calling a language element, logi.CAD 3 calls the methods . logi.CAD 3 highlights p arameters as faulty when they have not been declared within the method.

Example 1 for order when calling an element
FUNCTION_BLOCK CallElement
VAR
Element1 : MyFB1;
END_VAR
 
METHOD PUBLIC Element1
END_METHOD
 
Element1(IN1:=1, IN2:=2); // The method "Element1" is called. 'IN1' and 'IN2' are highlighted as faulty.
Element1(IN1:=1); // The method "Element1" is called. 'IN1' is highlighted as faulty.
Element1(); // The method "Element1" is called.
END_FUNCTION_BLOCK
 
FUNCTION_BLOCK MyFB1
VAR_INPUT
IN1 : int;
IN2 : int;
END_VAR
VAR_OUTPUT
OUT1 : int;
END_VAR
OUT1 := IN1 + IN2 +2;
END_FUNCTION_BLOCK
 
FUNCTION Element1
VAR_INPUT
IN1 : int;
END_VAR
VAR_OUTPUT
OUT1 : int;
END_VAR
END_FUNCTION

If the declaration of the method is missing (see example2), logi.CAD 3 calls the function block instance.

Example 2 for order when calling an element
FUNCTION_BLOCK CallElement
VAR
Element1 : MyFB1;
END_VAR
 
Element1(IN1:=1, IN2:=2); // The function block instance "Element1" is called.
Element1(IN1:=1); // The function block instance "Element1" is called.
Element1(); // The function block instance "Element1" is called.
END_FUNCTION_BLOCK
 
FUNCTION_BLOCK MyFB1
VAR_INPUT
IN1 : int;
IN2 : int;
END_VAR
VAR_OUTPUT
OUT1 : int;
END_VAR
OUT1 := IN1 + IN2 +2;
END_FUNCTION_BLOCK
 
FUNCTION Element1
VAR_INPUT
IN1 : int;
END_VAR
VAR_OUTPUT
OUT1 : int;
END_VAR
END_FUNCTION

Only, if the declaration of the function block instance is missing as well (see example 3), logi.CAD 3 calls the f unction. logi.CAD 3 highlights p arameters as faulty when they have not been declared within the function.

Example 3 for order when calling an element
FUNCTION_BLOCK CallElement
 
Element1(IN1:=1, IN2:=2); // The function "Element1" is called. 'IN2' is highlighted as faulty.
Element1(IN1:=1); // The function "Element1" is called.
Element1(); // The function "Element1" is called.
END_FUNCTION_BLOCK
 
FUNCTION_BLOCK MyFB1
VAR_INPUT
IN1 : int;
IN2 : int;
END_VAR
VAR_OUTPUT
OUT1 : int;
END_VAR
OUT1 := IN1 + IN2 +2;
END_FUNCTION_BLOCK
 
FUNCTION Element1
VAR_INPUT
IN1 : int;
END_VAR
VAR_OUTPUT
OUT1 : int;
END_VAR
END_FUNCTION