Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

=> Used for a Non-Output Parameter

=> captures a value out of an OUTPUT parameter into a caller variable. Using it for an INPUT or IN_OUT parameter is a direction mismatch — those parameters expect := to pass a value into the call.

Erroneous code example:

FUNCTION_BLOCK fb
VAR_INPUT in_val : DINT; END_VAR
END_FUNCTION_BLOCK

PROGRAM main
VAR
    instance : fb;
    source   : DINT;
END_VAR
    instance(in_val => source);  // invalid: ':=' expected for an input parameter
END_PROGRAM

To fix, use := for the input (or in-out) parameter:

PROGRAM main
VAR
    instance : fb;
    source   : DINT;
END_VAR
    instance(in_val := source);  // correct
END_PROGRAM