Evaluation of functions

Top  Previous  Next

Below is an example of the evaluation of a function.

 

 

Example:

INCLUDE rtcu.inc
 
FUNCTION Add : INT;
 
VAR_INPUT
  a : INT;
  b : INT;
  c : INT;
END_VAR;
 
  Add := a+b+c; // Make the our function return the sum of the 3 numbers
 
END_FUNCTION;
 
 
VAR
  a : INT;
END_VAR;
 
PROGRAM test;
 
BEGIN
 
  a:= Add(a:=3, b:=4, c:=10); // 'a' will be 17 after the call
 
END;
 
END_PROGRAM;