NEW CODE REQUEST: For/Next Loops

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

NEW CODE REQUEST: For/Next Loops

Post by Mckorr » Tue Jul 22, 2003 9:29 am

Was wondering if someone could come up with a way to make MQ support some sort of For loop, either a classic For/Next or using the CPP format. Would be much cleaner than the current looping set up using labels, variables, incrementing, and /if, changing 4 lines into 1 or 2 and making scripts much easier to read (and write).
MQ2: Think of it as Evolution in action.

GoatFoot
a lesser mummy
a lesser mummy
Posts: 68
Joined: Fri Jan 17, 2003 1:48 am

Post by GoatFoot » Tue Jul 22, 2003 2:59 pm

MQ has for/next loops, details can be found in the readme.

I'll grant that do loops would be cool, but I don't know how much of a priority they should rate given they'd give us 0 increase in functionality.

The mod I'd prefer over all others would be increased variable scoping/name space. I'd like each variable set in each #include to be in a seperate namespace from the variables in any other #include, or in the main proggy.

On the other hand, what we have now is certainly working just fine.

kaz
a ghoul
a ghoul
Posts: 103
Joined: Tue Jan 14, 2003 4:09 am

Post by kaz » Tue Jul 22, 2003 5:01 pm

rofl, this is classic, honestly no offense McKorr but its hillarious when a MQ "Dev" asks to have a feature added thats already there.

Zxeses
a ghoul
a ghoul
Posts: 103
Joined: Tue Jan 07, 2003 4:17 pm

for/next

Post by Zxeses » Tue Jul 22, 2003 6:12 pm

For anyone out there who really are programmers and not just macro scripters, you know all to well that the for/next loops in MQ are a far cry from real for/next loops in a genuine scripting/programing language.

I think the point of the post is to consider improvement by trying to show where the current system fails.

Right now, the for/next loops arnt much better then a /varadd and a /goto.

For example, a real programing language might look something like this:
(assuming these languages were tweeked to accept EQ / commands.)

Code: Select all

for (x=$char(x),y=$char(y); x<=destX, y<=destY; ++x, ++y)
  /face loc x,y
  /press down up
next
In a real for loop, you can increment more then +1, you can add by 5, divide by 10, whatever math seems reasonable. Some languages let you call functions to do the math for you.


So you see, there is room for improvment. Making MQ better is what this is about. Coders think this way, its in our blood.



-Zx

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Wed Jul 23, 2003 10:48 am

kaz wrote:rofl, this is classic, honestly no offense McKorr but its hillarious when a MQ "Dev" asks to have a feature added thats already there.
Yeah, but like a classic programmer I never read the manual... :P

Honestly, I've pretty much never used MQ for tradeskills until recently, so there are a whole host of functions I've either never used or, more likely, don't know they exist at all.

L124RD made me a dev so I could work on the mouse stuff, and if you remember in the early days that was kinda kept secret so we wouldn't be overrun with posts and PMs demanding it be finished. The dev thing simply allowed me to work with the other devs behind the scene until we had a good working beta to release.

So... it was a dumb question, and I'm properly embarassed :oops:
MQ2: Think of it as Evolution in action.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Wed Jul 23, 2003 10:59 am

In a real for loop, you can increment more then +1, you can add by 5, divide by 10, whatever math seems reasonable. Some languages let you call functions to do the math for you.
If I understand the readme correctly (see, I went back and read it), you can increment by any value you want using Step. The problem with your above example is that the current for/next loop does not handle arrays, meaning nested loops and calculations to accomplish the same thing.
MQ2: Think of it as Evolution in action.