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
Hi is there some possibility to skip some part in code during compiling code. Based on if with Constant value?
Something like this in C#. I've found pragmas in CODESYS, but my idea is that based on constant value will be called certain lines of code.
C#
\#ifDEBUG
Β Β Console.WriteLine("Debug version");
\#endifPossibilityinCODESYS?
VAR
Β Β diNumber: INT;END_VARVARCONSTANT
Β Β iDebug:INT:=1;END_VAR//incasethatiDebugis2wholecodeisskippedincompilation
{IFhasvalue(iDebug,1)}
(*Β thefollowingcodeisonlyprocessedinApp1*)
{info'value is 1'}
getnumberofadapters(ADR(diNumber));y :=1;
{ELSIFhasvalue(iDebug,2)}
(*Β thefollowingcodeisonlyprocessedinApp2*)
{info'value is 2'}
y :=2;
{ELSE}
{info'value is none'}
y :=3;
{END_IF}
Reason why I'm asking is that in some PLC is unsupported some library and I want to avoid error during download such as unresolved reference to getnumberofadapters
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi is there some possibility to skip some part in code during compiling code. Based on if with Constant value?
Something like this in C#. I've found pragmas in CODESYS, but my idea is that based on constant value will be called certain lines of code.
Reason why I'm asking is that in some PLC is unsupported some library and I want to avoid error during download such as unresolved reference to getnumberofadapters