<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Endless FOR Loop with CoDeSys 2.3.9.x</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/157026f4e3/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/157026f4e3/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/157026f4e3/</id><updated>2020-02-27T22:44:10.581000Z</updated><subtitle>Recent posts to Endless FOR Loop with CoDeSys 2.3.9.x</subtitle><entry><title>Endless FOR Loop with CoDeSys 2.3.9.x</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/157026f4e3/?limit=25#e73f" rel="alternate"/><published>2020-02-27T22:44:10.581000Z</published><updated>2020-02-27T22:44:10.581000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.comd42dcb074a50c450888af6929f68772d1b89827a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;no you are in error, as it is overflowing, &lt;/p&gt;
&lt;p&gt;when the test is on zero before adding it would not start at all&lt;/p&gt;
&lt;p&gt;when the test is on 255 then it would not run the last one. And yes correct you get endless loop.&lt;/p&gt;
&lt;p&gt;this is same for word and dword and for int,dint all same problem.&lt;/p&gt;
&lt;p&gt;very old problem even in machinelanguage was this a problem.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Endless FOR Loop with CoDeSys 2.3.9.x</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/157026f4e3/?limit=25#dc55" rel="alternate"/><published>2020-02-27T22:44:08.924000Z</published><updated>2020-02-27T22:44:08.924000Z</updated><author><name>yanapa</name><uri>https://forge.codesys.com/u/yanapa/</uri></author><id>https://forge.codesys.com7e458a66f04747736617d3dc3418620bec377daa</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;PROGRAM&lt;/span&gt; &lt;span class="nv"&gt;PLC_PRG&lt;/span&gt;
&lt;span class="nv"&gt;VAR&lt;/span&gt;
   &lt;span class="nv"&gt;i&lt;/span&gt; : &lt;span class="nv"&gt;BYTE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;Test&lt;/span&gt; : &lt;span class="nv"&gt;WORD&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_VAR&lt;/span&gt;
&lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="nv"&gt;TO&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt; &lt;span class="k"&gt;DO&lt;/span&gt;
   &lt;span class="nv"&gt;Test&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;Test&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_FOR&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;Test&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;There is a mistake in the IEC61131 compiler, the loop exit condition must be verified before increasing the i value and when exiting just increase once more like other compilers.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>