Loop doesn't stop when flag is set?
<p>I am developing a program in which I need to stop a loop when a flag is true. This is a short example of that I want:</p>

<pre><code>var aux = true;
for(i=0; i &lt; limit &amp;&amp; aux; i++)
{
   ...
   if (condition)
      aux = false;
}
</code></pre>

<p>When the condition should end the loop. But this is not true. What is the problem?</p>

<p>EDIT:</p>

<p>The code is as follows:</p>

<pre><code>aux = true; 
for(j=posX+1; j &lt;= limitXTop &amp;&amp; aux; j++)
  if(j != limiteXSuperior)
  {
     if(map.getXY(j,posY)[0] == 2)
     {
        aux = false;
     }
     else
        // Change
     ...
  }
  ...
</code></pre>

<p>I print a message to check if the execution enter in the IF and it enter.</p>
