Operator: + (Addition)

Top  Previous  Next

The + operator adds two integer or floating-point numbers or strings together and returns the result.

 

Using the '+' operator is much easier and more efficient than using the strConcat() function.

See example 2 below.

 

 


Example 1:

 

INCLUDE rtcu.inc
 
VAR
  a : INT;
  b : INT;
END_VAR;
 
PROGRAM test;
 
BEGIN
  ...
  a := b + 10;
  ...
END;
 
END_PROGRAM;

 

 

 

Example 2 :

 

INCLUDE rtcu.inc
 
VAR
  a : STRING;
  b : STRING;
  c : STRING;
END_VAR;
 
PROGRAM test;
 
  a := "Hello";
  b := "World";
  c := a + " big " + b;        // c will be equal to "Hello big World".
  ...
END_PROGRAM;