CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Fri Sep 21, 2018 9:08 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Feb 21, 2018 12:26 pm 
Offline

Joined: Mon Jun 27, 2016 7:38 pm
Posts: 2
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.
Code:
C#
#if DEBUG
    Console.WriteLine("Debug version");
#endif

Possibility in CODESYS?
VAR
   diNumber: INT;
END_VAR
VAR CONSTANT
   iDebug:INT:=1;
END_VAR

//in case that iDebug is 2 whole code is skipped in compilation

{IF hasvalue(iDebug,1)}
(*  the following code is only processed in App1 *)
{info 'value is 1'}
getnumberofadapters(ADR(diNumber));
y := 1;
{ELSIF hasvalue(iDebug,2)}
(*  the following code is only processed in App2 *)
{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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited