Search code examples
plcsiemens

SCL code: tag FUNCTION not defined on TIA


I want to create a new SCL function with TIA 15.1. I chose Program blocks => Add new block => Function. When I write the keyword FUNCTION in my file I get the following error: tag FUNCTION not defined. This is the same for others keywords like VAR for example.

My Code:

FUNCTION "test" :Void

VAR
    V1: Bool;
END_VAR

END_FUNCTION

I searched the web but there is not a lot of documentation on the topic. Any idea to solve the problem?


Solution

  • By default the way you need to do this is a little different than the old stuff. You need to define your variables in the table and and just write code in the editor. You don't add the function, var, var_in, etc. keywords.

    enter image description here

    However, new to V15.1 you can select text view under Options->Settings->PLC Programming->SCL->Interface and select Text view. If you create a new function now it will let you enter the variables using var, var_in, etc. But make sure you create a new function block. Also, this only works with SCL.

    enter image description here

    enter image description here