Page 1 of 2

/for /next bug

Posted: Tue Aug 17, 2004 1:44 am
by Sparr
if there is a /next inside a /if inside a /for, the /for will fail to stop at the proper value

Code: Select all

Sub Main
 /declare x int local
 /for x 1 to 7
  /if (${x}%2) /next x
  /echo ${x}
 /next x
/return
this produces 2 4 6 8 instead of 2 4 6 (end).

Code: Select all

Sub Main
 /declare x int local
 /for x 1 to 7
  /if (!(${x}%2)) /echo ${x}
 /next x
/return
this produces the proper output.

Posted: Tue Aug 17, 2004 2:54 am
by dont_know_at_all
Why is that a bug?

Posted: Tue Aug 17, 2004 2:58 am
by Sparr
because the /for should end if ${x} > 7

Posted: Tue Aug 17, 2004 3:08 am
by dont_know_at_all
Sparr wrote:because the /for should end if ${x} > 7
What does "end" mean?

Posted: Tue Aug 17, 2004 3:09 am
by Sparr
not iterate again

Posted: Tue Aug 17, 2004 3:09 am
by dont_know_at_all
It doesn't.

Posted: Tue Aug 17, 2004 3:15 am
by Cr4zyb4rd
Well, it's not QUITE a bug, but it's bug-ish

Code: Select all

Sub Main 
  /declare x int local 
  /for x 1 to 7 
    /echo ${x}
  /next x 
  /echo ${x}
/return 
yield's 1-8, as one might or might not expect, and this is what Sparr's seeing.

edit/addition:

Code: Select all

  /for x 1 to 7 
  /next x 
  /next x
  /next x
Gives no error, while just

Code: Select all

/next x
in by itself will return "/next without matching /for". Perhaps the /for needs to be destroyed (or whatever the word is..) when the ending condition is met?

Posted: Tue Aug 17, 2004 3:16 am
by Sparr
then how does '8' get /echo'd?

Posted: Tue Aug 17, 2004 3:18 am
by dont_know_at_all
No, that's not what sparr is complaining about.

Posted: Tue Aug 17, 2004 3:20 am
by dont_know_at_all
/next x == increment x and go back to the previous /for statement if x < limit

what should it do?

Posted: Tue Aug 17, 2004 3:26 am
by Sparr
what it should do:

/next x == increment x and go back to the previous /for statement

and the /for statement should be doing the x<=limit checking and going to the 'closing' /next if x>limit

this would be easier with {} after the /for instead of /next at the end.

this is part of the reason i advocate a pre-existing scripting language for MQ, fixing (or working around) problems like this would no longer be a problem

Posted: Tue Aug 17, 2004 3:28 am
by Cr4zyb4rd
you guys are going fast and furious...read my edit above :)

Posted: Tue Aug 17, 2004 3:30 am
by dont_know_at_all
sparr, write this down and save it on your desktop

ONLY USE ONE /NEXT FOR EACH /FOR AND YOU WON'T CONFUSE THE MQ SCRIPTING LANGUAGE WITH ANYTHING ELSE AND WHINE ABOUT IT.

Posted: Tue Aug 17, 2004 3:31 am
by Cr4zyb4rd
LMAO I was kinda thinking that myself. I think /next does what it's supposed to, considering how it's implemented, but a {} syntax would indeed be better.

Posted: Tue Aug 17, 2004 3:36 am
by Sparr
just one /next per /for really hurts... id have to rewrite most of the code ive ever written if that restriction was in other languages