Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Boolean function as a IF condition CODESYS

ashoksr90
2023-05-05
2023-05-05
  • ashoksr90 - 2023-05-05

    I have a function calling a function, in ST and both outputs are BOOLEAN

    I am trying a short hand

    IF FUNCTION2
    THEN
    FLAG := TRUE;
    END_IF

    After Compilation I receive an error saying Type 'FUNCTION2' cannot be converted to Type Boolean.

    Any suggestions on how I can use this short hand?

     
  • tvm - 2023-05-05
    IF FUNCTION2() THEN
        FLAG:= TRUE;
    END_IF
    

    The () brackets call the function. Without them you're evaluating the function itself as it if was a data type, without actually running the code in it.

     

Log in to post a comment.