Sign in to follow this  
Followers 0
Valik

AutoIt Errors To Stdout - Code

4 posts in this topic

#1 ·  Posted (edited)

This is all that's necessary to make JdeB's idea found here work.

A compiled version can be found http://www.autoitscript.com/fileman/users/Valik/autoit3.exe

This only works with an editor capable of grabbing the data, such as SciTE. The line I used to test with in SciTE was:

autoit3dir=C:\Path\To\Modified\File
command.go.$(au3)=$(autoit3dir)\autoit3.exe /ErrorStdOut "$(FilePath)"

In globaldata.h, globaldata.cpp, add variable:

bool g_bStdOut;

In Application.cpp:

Initialize g_bStdOut to false in AutoIt_App::AutoIt_App()

In AutoIt_App::ParseCmdLine() after the if block looking for a /c request, add this:

else if (stricmp("/ErrorStdOut", szTemp) == 0)
{
    g_bStdOut = true;
    if (nNumParams == 1)
    {
        pvTemp->ArraySubscriptClear();                // Reset the subscript
        pvTemp->ArraySubscriptSetNext(1);            // Array is 1 element (num params)
        pvTemp->ArrayDim();                            // Dimension array

        pvTemp->ArraySubscriptClear();                // Reset the subscript 
        pvTemp->ArraySubscriptSetNext(0);            // Set subscript we want to access
        pvElement = pvTemp->ArrayGetRef();            // Get reference to the element
        *pvElement = 0;                                // $CmdLines[0] = 0
        return;
    }
    --nNumParams;    // Decrement because we strip the /ErrorStdOut from the command line
    g_oCmdLine.GetNextParam(szTemp);    // skip to the next item
}

Finally in script.cpp, modify these:

In FatalError(int iErr, int nCol):

if (g_bStdOut)
    printf("%s (%d) : ==> %s: \n%s \n%s\n",szInclude, nAutScriptLine, szText, szScriptLine, szOutput2 );
else
    MessageBox(g_hWnd, szOutput, szTitle, MB_IConstop | MB_OK | MB_SYSTEMMODAL | MB_SETFOREGROUND);

And in FatalError(int iErr, const char *szText2):

if (g_bStdOut)
    printf("%s (%d) : ==> %s: \n%s \n%s\n",szInclude, nAutScriptLine, szText, szScriptLine, szText2);
else
    MessageBox(g_hWnd, szOutput, szTitle, MB_IConstop | MB_OK | MB_SYSTEMMODAL | MB_SETFOREGROUND);
Edited by Valik

Share this post


Link to post
Share on other sites



Tested it sucessfully with textpad, Scite and Crimson with the test version i had ....

Just tried your version and it looks great !!!


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Forgot to mention, that code works for both versions of ParseCmdLine() so it needs to go into both.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0