/for /next bug

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

Sparr
a hill giant
a hill giant
Posts: 159
Joined: Mon Jun 24, 2002 5:41 am

/for /next bug

Post by Sparr » Tue Aug 17, 2004 1:44 am

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.
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Tue Aug 17, 2004 2:54 am

Why is that a bug?

Sparr
a hill giant
a hill giant
Posts: 159
Joined: Mon Jun 24, 2002 5:41 am

Post by Sparr » Tue Aug 17, 2004 2:58 am

because the /for should end if ${x} > 7
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Tue Aug 17, 2004 3:08 am

Sparr wrote:because the /for should end if ${x} > 7
What does "end" mean?

Sparr
a hill giant
a hill giant
Posts: 159
Joined: Mon Jun 24, 2002 5:41 am

Post by Sparr » Tue Aug 17, 2004 3:09 am

not iterate again
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Tue Aug 17, 2004 3:09 am

It doesn't.

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Tue Aug 17, 2004 3:15 am

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?
Last edited by Cr4zyb4rd on Tue Aug 17, 2004 3:22 am, edited 1 time in total.

Sparr
a hill giant
a hill giant
Posts: 159
Joined: Mon Jun 24, 2002 5:41 am

Post by Sparr » Tue Aug 17, 2004 3:16 am

then how does '8' get /echo'd?
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Tue Aug 17, 2004 3:18 am

No, that's not what sparr is complaining about.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Tue Aug 17, 2004 3:20 am

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

what should it do?

Sparr
a hill giant
a hill giant
Posts: 159
Joined: Mon Jun 24, 2002 5:41 am

Post by Sparr » Tue Aug 17, 2004 3:26 am

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
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Tue Aug 17, 2004 3:28 am

you guys are going fast and furious...read my edit above :)

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Tue Aug 17, 2004 3:30 am

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.

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Tue Aug 17, 2004 3:31 am

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.

Sparr
a hill giant
a hill giant
Posts: 159
Joined: Mon Jun 24, 2002 5:41 am

Post by Sparr » Tue Aug 17, 2004 3:36 am

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
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]