This is not a standard feature of ST or FBD but there is a small hack to achieve this. See the example below. It only works if the input variable is named "in" (the same works for output variable named "out") and the type is array. FUNCTION InDemo : LINT VAR i : INT; END_VAR VAR_INPUT In : ARRAY[0..63] OF BOOL; END_VAR (*function block's body*) result := 0; FOR i := 0 TO 63 DO // nejaky kod IF In[i] THEN result := result + 1; END_IF; END_FOR; InDemo := result; END_FUNCTION