AutoIt DebugPrint() function and trace output
Modifications for use with a debugger

Hi,

Just want to propose some changes for AutoIt to allow easier script
debugging. There has been a lot of talk in other topics about the need
for debugging tools. 

The changes detailed below are a trace output and a DebugPrint() function.  
Both of these use the win32 OutputDebugString() to spit messages to a
debugger - either Visual Studio, or DebugView from www.sysinternals.com.
DebugView can log the debug output to a file and perform remote debugging.

Trace output is enabled with AutoItSetOption('DebugOutputEnabled',1)
Debug output is generated with DebugPrint($my_var)

Files attached to the post have the test executable, script and output.

Based on sources autoit-v3.1.0-src.exe

[FONT=Courier]
Trace Output:
D:\Projects\AutoIt\Source\src\globaldata.h(104):
    extern bool g_bDebugOutputEnabled;

D:\Projects\AutoIt\Source\src\globaldata.cpp(108):
    bool g_bDebugOutputEnabled; // True when debugger output is allowed

D:\Projects\AutoIt\Source\src\application.cpp(95):
    g_bDebugOutputEnabled = false;

D:\Projects\AutoIt\Source\src\script_misc.cpp(1770): (AutoIt_Script::F_AutoItSetOption)
    else if ( !stricmp(szOption, "DebugOutputEnabled") ) // DebugOutputEnabled
    {
        vResult = (int)g_bDebugOutputEnabled; // Store current value

        if (nValue == 0)
            g_bDebugOutputEnabled = false;
        else
            g_bDebugOutputEnabled = true;
    }

D:\Projects\AutoIt\Source\src\script.cpp(864): (AutoIt_Script::Execute)
    if (g_bDebugOutputEnabled)
    {
        // code from AutoIt_App::SetTrayIconToolTip
        char szTip[63+1];
        AString sTip(_MAX_PATH);
        int nCurLine;
        nCurLine = nScriptLine-1;
			
        sTip += g_oScriptFile.GetIncludeFileName(g_oScriptFile.GetIncludeID(nCurLine));
        sprintf(szTip, ": Line %03d: ", g_oScriptFile.GetAutLineNumber(nCurLine));
        sTip += szTip;[/FONT]
        sTip += g_oScriptFile.GetLine(nCurLine);
        sTip += "\n";

        OutputDebugString(sTip.c_str());
    }

    // Do the lexing (convert the line into tokens) - stored in LineTokens
    Lexer(nScriptLine-1, szScriptLine, LineTokens);

DebugPrint():
D:\Projects\AutoIt\Source\src\script.cpp(219):
    {"DEBUGPRINT", &AutoIt_Script::F_DebugPrint, 1, 1},

D:\Projects\AutoIt\Source\src\script.h(850):
    AUT_RESULT  F_DebugPrint(VectorVariant &vParams, Variant &vResult);

D:\Projects\AutoIt\Source\src\script_misc.cpp(321):
    AUT_RESULT AutoIt_Script::F_DebugPrint(VectorVariant &vParams, Variant &vResult)
    {
        vResult = 1;
        OutputDebugString(vParams[0].szValue());

        return AUT_OK;
    } // F_DebugPrint()

[/FONT]
