Jump to content

AutoIt3Wrapper - "run" with stop on error by parameter


Recommended Posts

@Jos

In my project PSPad4AutoIt3 I am now implementing the "Run" commands (Run, Compile, Compile Dialog, and Check). If I execute a script via "Run" and it contains errors, then the execution should be aborted and the output should be displayed in the log window of PSPad.

Is there a parameter I can pass to AutoIt3Wrapper to stop on errors?

In my project I don't want a file to be changed in the AutoIt or SciTE directory. Therefore a start parameter for AutoIt3Wrapper would be good.

I could also do a "Check" first and then start "Run", but I don't know if it will take long with large scripts. And it would be weird, because when AutoIt3Wrapper is started, it also executes a "check". That would be a lot of checks. 😁

How can I call "Run" with "Stop on error" without changing a file in the SciTE directory?

Bernd.

Edited by Professor_Bernd
Link to comment
Share on other sites

Hi Jos.

In PSPad I call my "AutoIt3_CompilerRunner.au3" (short: CompilerRunner) and give it the current script "Example.au3".

CompilerRunner now starts AutoIt with AutoIt3Wrapper and Example.au3.

$sAutoIt3Command = _
        '"' & @ProgramFilesDir & '\AutoIt3\AutoIt3.exe" _
        & ''' & @ProgramFilesDir & '\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3'' _
        & ' /prod /in "' & $sExampleAu3 & '" /run /ErrorStdOut'

      $g_iAutoIt3PID = Run($sAutoIt3Command, "", @SW_HIDE, $STDOUT_CHILD)

If there are no errors in Example.au3, e.g. an MsgBox is shown. If there are errors in Example.au3, then errors are displayed in the log window of PSPad, but Example.au3 runs anyway and shows e.g. the MsgBox.

My goal is that if there are errors in Example.au3, the execution should be aborted (e.g. the MsgBox should NOT be displayed). How can I do this without changing files in the SciTE directory? Is there a start parameter for AutoIt3Wrapper that stops the execution of Example.au3 when errors are detected?

Sorry for my bad explanation.

Link to comment
Share on other sites

  • Developers

Ok, so what does the test script look like and the returned console output so I understand what you are trying? :) 

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Please excuse that it took so long. It is not so easy for me to create an example and post it here.

The test script

MsgBox(0, "Example", "This is an example")

$sTest = Hello ; An error occurs here because the quotes are missing. 
               ; But the MsgBox is displayed anyway.

and the returned console output in PSPad

Quote

+>16:52:45 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0   Keyboard:00000407  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:  utf8.auto.check:
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\User1\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\User1\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\User1\Desktop\Example.au3
"C:\Users\User1\Desktop\Example.au3"(5,15) : error: Hello(): undefined function.
$sTest = Hello
~~~~~~~~~~~~~~^
C:\Users\User1\Desktop\Example.au3 - 1 error(s), 0 warning(s)
!>16:52:46 AU3Check ended. Press F4 to jump to next error.rc:2  <== Here the execution should stop, but it continues running, shows the MsgBox etc.
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\User1\Desktop\Example.au3"  /errorstdout
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"C:\Users\User1\Desktop\Example.au3"(5,1) : error: ==> Unknown function name.:
$sTest = Hello
$sTest = ^ ERROR

->16:52:54 AutoIt3.exe ended.rc:1
+>16:52:54 AutoIt3Wrapper Finished.

In SciTE the execution is stopped and the console output looks like this.

Quote

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\User1\Desktop\Example.au3" /UserParams    
+>17:06:26 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0   Keyboard:00000407  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\User1\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\User1\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\User1\Desktop\Example.au3
"C:\Users\User1\Desktop\Example.au3"(3,70) : error: Hello(): undefined function.
$sTest = Hello ; An error occurs here because the quotes are missing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\User1\Desktop\Example.au3 - 1 error(s), 0 warning(s)
!>17:06:26 AU3Check ended. Press F4 to jump to next error.rc:2  <== Here the execution was stopped correctly.
+>17:06:26 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 0.6606

Bernd.

Edited by Professor_Bernd
Text passages highlighted.
Link to comment
Share on other sites

  • Developers

Ah ok,  I understand now. You need to modify AutoIt3Wrapper in case you want to integrate it with another editor  as there are all kinds of dependencies in there now.
In this case this line 3537 is causing the issue:

If $Option <> "AU3Check" And ProcessExists("SciTe.exe") Then

 as it is looking for SciTE.exe.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
Just now, Professor_Bernd said:

The users should be able to use SciTE and PSPad in parallel. Is it possible to solve this without changing anything in AutoIt3Wrapper?

Possibly,  so let me know when you think you have a solution for it that I could integrate into my version. ;) 

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks for the tip. I changed the line and it looks good!

If $Option <> "AU3Check" And ProcessExists("SciTe.exe") Then

If $Option <> "AU3Check" And (ProcessExists("SciTe.exe") or ProcessExists("PSPad.exe")) Then

The output in SciTE:

Quote

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\User1\Desktop\Example.au3" /UserParams    
+>17:06:26 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0   Keyboard:00000407  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\User1\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\User1\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\User1\Desktop\Example.au3
"C:\Users\User1\Desktop\Example.au3"(3,70) : error: Hello(): undefined function.
$sTest = Hello ; An error occurs here because the quotes are missing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\User1\Desktop\Example.au3 - 1 error(s), 0 warning(s)
!>17:06:26 AU3Check ended. Press F4 to jump to next error.rc:2  <== Here the execution was stopped correctly.
+>17:06:26 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 0.6606

And the output in PSPad:

Quote

+>17:45:46 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0   Keyboard:00000407  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\User1\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\User1\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\User1\Desktop\Example.au3
"C:\Users\User1\Desktop\Example.au3"(3,70) : error: Hello(): undefined function.
$sTest = Hello ; An error occurs here because the quotes are missing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\User1\Desktop\Example.au3 - 1 error(s), 0 warning(s)
!>17:45:46 AU3Check ended. Press F4 to jump to next error.rc:2  <== Here the execution was stopped correctly.
+>17:45:46 AutoIt3Wrapper Finished.

Excellent! That works well and you're the best!  👍

On my own computer I can change that myself. Can you change that in general? Do you need any more information?

 

On this occasion: In line 959 is a similar thing ;)

If $Option <> "Tidy" And ProcessExists("SciTe.exe") Then

 

Link to comment
Share on other sites

  • Professor_Bernd changed the title to AutoIt3Wrapper - "run" with stop on error by parameter
  • Developers

I have had a look back in the SVN repo and that test has been there since the beginning of the SVN repo, but it serves no purpose anymore as the reason for that test is gone in that part of the code. So I have cleaned it up a little and made a new beta version available you can test with now. Both au3check and tidy logic is updated.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hi Jos, something went wrong. With the beta version of AutoIt3Wrapper.au3 PSPad does not stop if there is an error in the script. And now the same in SciTE, it is no stopping anymore.

My Test: I open Example.au3 in SciTe and PSPad and press F5. Unfortunately the execution is not stopped in both and the MsgBox appears.

Did I do something wrong? :huh2:

Link to comment
Share on other sites

  • Developers

mmm ... you are right...thought I tested all options but made a pretty basic error in the rewrite. Please download the beta version again and try.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It's looking better already! If an error is detected in Example.au3, the execution stops in both (PSPad and SciTE).

Output

Quote

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\User1\Desktop\Example.au3" /UserParams    
+>19:54:32 Starting AutoIt3Wrapper v.19.102.1901.7 SciTE v.4.1.2.0   Keyboard:00000407  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\User1\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\User1\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\User1\Desktop\Example.au3
"C:\Users\User1\Desktop\Example.au3"(3,70) : error: Hello(): undefined function.
$sTest = Hello ; An error occurs here because the quotes are missing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\User1\Desktop\Example.au3 - 1 error(s), 0 warning(s)
!>19:54:32 AU3Check ended. Press F4 to jump to next error.rc:2
@@ Debug(3538) : $INP_AU3Check_Stop_OnWarning = n  <==== Is that intentional?
>Error code: 0
+>19:54:32 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 0.6602

And then there's something funny: When I run Example.au3 in SciTE and then run it in PSPad, Scite makes an error-jump (F4) every time I press F5 in PSPad.

Bernd.

Link to comment
Share on other sites

  • Developers
8 minutes ago, Professor_Bernd said:

then there's something funny: When I run Example.au3 in SciTE and then run it in PSPad, Scite makes an error-jump (F4) every time I press F5 in PSPad.

That's because when SciTE is running, AutoIt3Wrapper assumes it is used to run it and it send a command to SciTE to jump to the first errorline or else the errors are cleared:

Line 3520:

If $ExitCode Then
            ; Jump to first Annotation in case there are Warnings or Errors
            If $INP_Jump_To_First_Error = "y" Then
                Run('"' & @AutoItExe & '" "' & @ScriptFullPath & '" /Jump2FirstError ' & @AutoItPID)
            EndIf
        Else
            ; Clear Annotation in case there are no Warnings or Errors anymore
            SendSciTE_Command($My_Hwnd, $SciTE_hwnd, "extender:dostring scite.SendEditor(SCI_ANNOTATIONCLEARALL)")
        EndIf

Made  small update to AutoIt3Wrapper to get rid of that debugline.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

1 hour ago, Jos said:

That's because when SciTE is running, AutoIt3Wrapper assumes it is used to run it and it send a command to SciTE to jump to the first errorline or else the errors are cleared:

Thanks for the info. 😊

 

Now I've tested the beta version a bit more extensively, and it looks good! I tested "Run", "Compile", "Compile with Dialog", and "Check". In case of errors in the test scripts both stop the execution (PSPad and SciTE). 👍

By the way, what is the normal behavior for warnings? Should the execution then continue or be stopped? Currently the execution continues even with warnings.

I am very happy that this worked so well. Thank you very much for your good work! I am impressed!

Can I get your permission to distribute your AutoIt3Wrapper.au3 in my PSPad4AutoIt3 Improvement Kit? It would be very kind of you. :)

Bernd.

Link to comment
Share on other sites

  • Developers
2 minutes ago, Professor_Bernd said:

By the way, what is the normal behavior for warnings?

Au3check warnings? Just check the helpfile were you can see the options, but default behaviour is to continue on warnings, which can be adapted by the directive:

#AutoIt3Wrapper_Au3Check_Stop_OnWarning=        ;(Y/N) Continue/Stop on Warnings.(Default=N)

 

4 minutes ago, Professor_Bernd said:

Can I get your permission to distribute your AutoIt3Wrapper.au3 in my PSPad4AutoIt3 Improvement Kit?

Sure, but thought I already answered...right? ;) 

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

I made some more changes:

  • Fixed Tidy stop on error logic error introduced in last versions.
  • Added check RunBySciTE to avoid sending the SciTE messages when not run by SciTE.

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...