Page 1 of 1

/endmacro not clearing vars

Posted: Fri Apr 02, 2004 1:27 am
by tonio
I noticed /endmacro was clearing arrays and timers, but not vars, starting a couple of releases ago (that is, less than a week ago). I checked the code and found this:

Code: Select all

// ***************************************************************************
// Function:    EndMacro
// Description: Our '/endmacro' command
// Usage:       /endmacro
// ***************************************************************************
VOID EndMacro(PSPAWNINFO pChar, PCHAR szLine)
{
    CHAR Buffer[MAX_STRING] = {0};
    DWORD i;
    PMACROBLOCK pPrev;
    PMACROSTACK pStack;
    PEVENTSTACK pEvent;
    PEVENTLIST pEventL;
    BOOL bKeepKeys = gKeepKeys;
    [color=red]BOOL bKeepVars = TRUE;[/color]
    BOOL bKeepTimers = FALSE;
    BOOL bKeepArrays = FALSE;
in MQ2MacroCommands.cpp.

Is this an oversight? I know it wasn't working like this before. I noticed because suddenly my macros were spewing a lot of "Variable so-and-so already defined" or something like that, when I stopped and restarted them.

Yes, I know you can pass arguments to /endmacro to keep or not keep arrays, vars, timers... but I was wondering why the default was changed, whether it was on purpose.

*Edit: funky BBCode end tag

Posted: Fri Apr 02, 2004 1:35 am
by ml2517
Lax changed this on purpose. Just throw a /zapvars right below your Sub Main in your macros.

Posted: Fri Apr 02, 2004 5:51 pm
by tonio
Oh, I just changed the code and re-compiled... figured it was an oversight (kinda like when Lax forgot to put Parms as the default instead of MQ2Data). If it's not, then np, I'll change it back and adjust. =)

Outta sheer curiosity, tho, what's the reason behind it? (Looked around the forums and didn't find it.) No, I'm not "questioning the dev's judgement"... I'm just curious. =)

Posted: Fri Apr 02, 2004 5:55 pm
by ml2517
I'd commented about /zapvars possibly causing issues when passing params to your macro. Nevermind.. it still seems to work strangly enough.

Posted: Fri Apr 02, 2004 6:28 pm
by Chaesar
I cannot find the thread atm, but the reason for the change was for those who use global variables in their /custombind commands. Lax had said that global variables didn't get cleared upon completion of macros, but later found that they did so he changed it.