I noticed a code evaluation error that I do not know if it is a language limitation, a bug or bad programming practice.

This code is to simulate the situation, I know I could have written the code differently, but in a hurry, I ended up writing like this.
Code:
//var %x = 500 | while (%x) { dec %x | echo -a %x | if (%x == 400) { break } }

When evaluating the code, it does not obey the hierarchy of brackets and breaks the while, because it considered the second statement (if) as true, but it is false.

Solution was to use:
Code:
//var %x = 500 | while (%x) { dec %x | echo -a %x | if (%x == 400) { break } | noop }


In remotes or aliases it works like this:
Code:
var %x = 500
while (%x) {
  dec %x
  echo -a %x
  if (%x == 400) {
    break
  }
}


I know I could have coded like this:
Code:
//var %x = 500 | while (%x) && (%x != 400) { dec %x | echo -a %x }

But as I said, was in a hurry...

Why do I think it's a bug?
Because the second statement (if) is giving as true, but it is false.

Now see the code below:
Code:
//if (1 == 1) { echo -a firts statement true | if (1 == 2) { echo -a second statement true } }

Here no printing occurs of "second statement true", unlike the first code with break.

Last edited by rockcavera; 02/02/17 07:33 AM.

rockcavera
#Scripts @ irc.VirtuaLife.com.br