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

Function Block - Error C0006

Mfleming79
2017-06-27
2017-06-30
  • Mfleming79 - 2017-06-27

    New to Codesys and expect that this is a syntax error. Tried to use the Oscat FB lib but the FB's do not have an output to them for some strange reason (maybe someone could help me here as well). From here I tried to build a new function but I get C0006 errors for the Var designation text. The text I wrote is as follows.

    FUNCTION HR_Of_DT : INT
    VAR_INPUT
    XDT: DATE_AND_TIME;
    END_VAR

    VAR_OUTPUT
    Hour_Of_DT : INT
    END_VAR

    The specific errors I have are as follows.

    [ERROR] Test: HR_Of_DT Device: PLC Logic: Application: C0006: 'END_VAR' expected instead of ''
    [ERROR] Test: HR_Of_DT Device: PLC Logic: Application: C0006: ';, :=, REF=, ( or [' expected instead of 'END_VAR'

     
  • Joan M - 2017-06-27

    Missing semicolon after Hour_Of_DT : INT

    Hope this helps...

     
  • Mfleming79 - 2017-06-27

    This fixed it thanks!

    On a side note, is there any reference materials for error codes? I had zero luck searching the web and the Codesys manual.

     
  • Joan M - 2017-06-27

    See the error itself:

    [ERROR] Test: HR_Of_DT Device: PLC Logic: Application: C0006: 'END_VAR' expected instead of ''

    HR_OF_DT, 6th line on the declaration section. END_VAR is missing.

    Of course END_VAR is not missing, but this is due the way compilers handle the check stage.
    If you are not ending the line using a semicolon then the next line belongs to the current one and therefore END_VAR is understood not as the reserved statement it is but as part of your declarations...

    There are codes that can be found in the help system, there are other codes that force you to understand what you are doing...

    A good tip is to search at the line it tells you and before as the error can be in a previous line but the compiler can't say it...

    Hope this helps.

     
  • nothinrandom - 2017-06-30

    I'd say just double click on the error next time. The IDE typically brings you to the exact line where it think it has encountered a fault.

     

Log in to post a comment.