A forum for reporting bugs NOT related to custom plugins.
Moderator: MacroQuest Developers
-
dont_know_at_all
- 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:55 am
what? are you trying to port your lame-ass C++ code to MQ2 scripting language?
Boggle.
-
Sparr
- a hill giant

- Posts: 159
- Joined: Mon Jun 24, 2002 5:41 am
Post
by Sparr » Tue Aug 17, 2004 4:00 am
no, im writing macros from scratch, then spending far too much time debugging problems in the macro caused by 'features' of the language.
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]
-
dont_know_at_all
- 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 4:02 am
Look at as a chance to improve your debugging skills.
-
Cr4zyb4rd
- Plugins Czar
- Posts: 1449
- Joined: Tue Jul 20, 2004 11:46 am
Post
by Cr4zyb4rd » Tue Aug 17, 2004 4:43 am
I'm intrigued. Please post what you're doing that can't be fixed by moving things around slightly or adding and "else" clause.
-
Sparr
- a hill giant

- Posts: 159
- Joined: Mon Jun 24, 2002 5:41 am
Post
by Sparr » Tue Aug 17, 2004 4:48 am
i was looping through bazaar results.
psudocode:
/for x 1 to bazaar.count
/if bazaar.itemx.name!=nameiwant /next x
do stuff
/next x
now that i know about this problem ive fixed the code as follows:
/for x 1 to bazaar.count
/if bazaar.itemx.name==nameiwant {
do stuff
}
/next x
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]
-
zanomo
- a hill giant

- Posts: 285
- Joined: Thu Jun 24, 2004 11:21 pm
Post
by zanomo » Tue Aug 17, 2004 5:14 am
I think the result produced (2, 4, 6, 8 echoed) was perfectly correct and would be bugged if otherwise.
Tracing the codes
Code: Select all
line statement
1 /for x 1 to 7
2 /if (${x}%2) /next x
3 /echo ${x}
4 /next x
And following the statement step by step (I haven't done this for quite awhile..

):
Code: Select all
step line initial final if action
X value X value eval
1 1 1 1 - /for
2 2 1 2 true /if-/next x
3 1 2 2 - /for
4 2 2 2 false /if
5 3 2 2 - /echo 2
6 4 2 3 - /next x
7 1 3 3 - /for
8 2 3 4 true /if-/next x
9 1 4 4 - /for
10 2 4 4 false /if
11 3 4 4 - /echo 4
12 4 4 5 - /next x
13 1 5 5 - /for
14 2 5 6 true /if-/next x
15 1 6 6 - /for
16 2 6 6 false /if
17 3 6 6 - /echo 6
18 4 6 7 - /next x
19 1 7 7 - /for
20 2 7 8 true /if-/next (exit for/next)
21 3 8 8 - /echo 8
22 4 8 8 - /next (exit for/next again)
23 end.
Would produce the result (echo 2 4 6 8) as you programmed it to...
-
zanomo
- a hill giant

- Posts: 285
- Joined: Thu Jun 24, 2004 11:21 pm
Post
by zanomo » Tue Aug 17, 2004 5:18 am
Sparr wrote:i was looping through bazaar results.
psudocode:
/for x 1 to bazaar.count
/if bazaar.itemx.name!=nameiwant /next x
do stuff
/next x
now that i know about this problem ive fixed the code as follows:
/for x 1 to bazaar.count
/if bazaar.itemx.name==nameiwant {
do stuff
}
/next x
Or to retain your logic flow using /goto:
Code: Select all
psudocode:
/for x 1 to bazaar.count
/if bazaar.itemx.name!=nameiwant /goto :not_nameiwant
do stuff
:not_nameiwant
/next x
-
Sparr
- a hill giant

- Posts: 159
- Joined: Mon Jun 24, 2002 5:41 am
Post
by Sparr » Tue Aug 17, 2004 5:22 am
on one part where i had more than two /next's i had to use the /goto solution, ended up abandoning /for completely on that one.
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]
-
wassup
- Official Guardian and Writer of TFM

- Posts: 1487
- Joined: Sat Oct 26, 2002 5:15 pm
Post
by wassup » Tue Aug 17, 2004 7:03 am
On a side note:
Code: Select all
Sub Main
/declare x int local
/for x 1 to 7
/if (${x}%2) /next x
/echo ${x}
/next x
/return
Isn't
${x}%2 considered a calculation?
I would have thought it would have to be:
Code: Select all
Sub Main
/declare x int local
/for x 1 to 7
/if (${Math.Calc[${x}%2].Int}) /goto :Next
/echo ${x}
:Next
/next x
/return
At least that is how I would have done it in a macro
-
Sparr
- a hill giant

- Posts: 159
- Joined: Mon Jun 24, 2002 5:41 am
Post
by Sparr » Tue Aug 17, 2004 7:05 am
yeah, you have to use math. i was just typing it off the top of my head :)
[img]http://www.trifocus.net/~sparr/sparr_rotate_sig_16.gif[/img]
-
Caladine
- a hill giant

- Posts: 164
- Joined: Fri Feb 13, 2004 9:29 pm
Post
by Caladine » Tue Aug 17, 2004 9:10 am
He's trying to use that first /next x like a continue; statement, which it can't actually be used as.
While it would be nice for the mq macro language to include a /break <variable name> and a /continue <variable name>, it's not particularly hard to use a /goto to get the same effect.