<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to how does the evaluation of the &lt;condition&gt; in an IF-statement work?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0a03c6ab10/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0a03c6ab10/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/0a03c6ab10/</id><updated>2020-02-27T14:05:17.104000Z</updated><subtitle>Recent posts to how does the evaluation of the &lt;condition&gt; in an IF-statement work?</subtitle><entry><title>how does the evaluation of the &lt;condition&gt; in an IF-statement work?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0a03c6ab10/?limit=25#c45c" rel="alternate"/><published>2020-02-27T14:05:17.104000Z</published><updated>2020-02-27T14:05:17.104000Z</updated><author><name>jan233321</name><uri>https://forge.codesys.com/u/jan233321/</uri></author><id>https://forge.codesys.comfe2cca8f538d04900673d25f52892f885ebcb98a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;+1 to list of FAQ of efficient runtime optimization in Codesys V3! Because the compiler is doing almost nothing in term of code efficiency...&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>how does the evaluation of the &lt;condition&gt; in an IF-statement work?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0a03c6ab10/?limit=25#be11" rel="alternate"/><published>2020-02-27T14:05:16.758000Z</published><updated>2020-02-27T14:05:16.758000Z</updated><author><name>chwizgl</name><uri>https://forge.codesys.com/u/chwizgl/</uri></author><id>https://forge.codesys.com7c7d0f9c9bfe269eafb482d4532ab91b430d4ef8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks a lot!&lt;/p&gt;
&lt;p&gt;For the sake of completeness let's mention that for the &lt;strong&gt;OR&lt;/strong&gt; statement there is also a corresponding &lt;strong&gt;OR_ELSE&lt;/strong&gt; statement&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>how does the evaluation of the &lt;condition&gt; in an IF-statement work?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0a03c6ab10/?limit=25#bbb9" rel="alternate"/><published>2020-02-27T14:05:16.406000Z</published><updated>2020-02-27T14:05:16.406000Z</updated><author><name>e.kislov</name><uri>https://forge.codesys.com/u/e-kislov/</uri></author><id>https://forge.codesys.comdbb254c54396994590435f6b0f12335d56ae65ea</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi.&lt;br/&gt;
Use AND_THEN operator.&lt;br/&gt;
&lt;a class="" href="https://help.codesys.com/webapp/_cds_operator_and_then;product=codesys;version=3.5.15.0" rel="nofollow"&gt;https://help.codesys.com/webapp/_cds_op ... n=3.5.15.0&lt;/a&gt; m &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>how does the evaluation of the &lt;condition&gt; in an IF-statement work?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/0a03c6ab10/?limit=25#f9b6" rel="alternate"/><published>2020-02-27T14:05:16.030000Z</published><updated>2020-02-27T14:05:16.030000Z</updated><author><name>chwizgl</name><uri>https://forge.codesys.com/u/chwizgl/</uri></author><id>https://forge.codesys.comb60528b276a1098419eb9be5953ad3d0e7e99ab9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I'm looking for runtime optimizations and have the following problem, which I can't find any answer to in the documentation:&lt;/p&gt;
&lt;p&gt;Let's assume, I have multiple conditions for an IF-statement, e.g.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;var1&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;FALSE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;var2&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;whatever&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;var1&lt;/span&gt; &lt;span class="nv"&gt;AND&lt;/span&gt; &lt;span class="nv"&gt;var2&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
    &lt;span class="c1"&gt;; // some code&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Is ```&lt;/p&gt;
&lt;p&gt;var1 AND var2&lt;/p&gt;
&lt;p&gt;&lt;code&gt;evaluated in any case? or does it abort the evaluation as soon as it sees that&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;var1 = FALSE&lt;/p&gt;
&lt;p&gt;```?&lt;/p&gt;
&lt;p&gt;Reason: Before I evaluate a complex IF-condition (var2), I would like to pre-check, if this is necessary (var1). The second condition is expensive but is not required in 99% of the cases.&lt;/p&gt;
&lt;p&gt;PS: Does anybody have a collection of such runtime optimization hints?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>