Clearing Variables - Calling macros from within each other

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Furiousness
a lesser mummy
a lesser mummy
Posts: 62
Joined: Tue Aug 26, 2003 3:48 pm

Clearing Variables - Calling macros from within each other

Post by Furiousness » Tue Oct 28, 2003 7:04 pm

Hi Guys

I have a macro that calls a similar copy of itself once it has finished, when running and the next macro starts I get Variable name already defined. So am guessing its holding onto the memory there somewhere. Anyway what I am after is how do I clear the memory? I just tried the /zapvars command but it seemed to have killed the variables for the next macro also (both macros have the same variable names).

Any thoughts appreciated.

Also I have a third macro which runs after the second, well its supposed to but it doesn't. Anyone played with calling macros one after the other from with each other?

Cheers

Fury

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

Post by Mckorr » Tue Oct 28, 2003 7:16 pm

Change the variable names for the second macro, or use local instead of global variables.

I typically build my macros in modules, then call the modules by use of the #include statement. So I have one master macro of about 10 lines, which calls 2 or 3 other macros as includes.

You could do that instead of having them chain call each other, and use /zapvars between include calls.
MQ2: Think of it as Evolution in action.

Furiousness
a lesser mummy
a lesser mummy
Posts: 62
Joined: Tue Aug 26, 2003 3:48 pm

Post by Furiousness » Tue Oct 28, 2003 7:34 pm

Ahhh yes, i see what you mean. The problem being though is that I am linkin the Sits.mac, which takes in starting params. I am using it to do subcombines as soon it has finished the initial combines.

eg /macro sits default "packet of kiola" "water "........
when this has run out of supplies it begins the next macro

/macro sits default "kiola" ..................

How would I imitate that using the include?

Cheers

Fury

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Tue Oct 28, 2003 7:56 pm

Try /zapvars?
- Plazmic

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

Post by Mckorr » Tue Oct 28, 2003 8:09 pm

#include sits.mac

Change "sub Main" to "sub SitsMain". Change /endmacro in sits.mac to /return.

Code: Select all

#inlcude sits.mac
sub Main
/call SitsMain param param param
/zapvars
/call SitsMain param param param
/endmacro
That will call sits.mac using the first set of parameters. When sits.mac is done it will return to this macro, which will zapvars and pass a new set of parameters.

Just make sure sub SitsMain ends with /return, not /endmacro, so it returns control to the calling macro instead of ending the whole process.
MQ2: Think of it as Evolution in action.