Sign in to follow this  
Followers 0
francys

Ignone error

26 posts in this topic

My simple code
 
Sleep(5000)
MsgBox(1,"aaa","aaa"
Sleep(3000)
MsgBox(1,"bbb","bbb")
Sleep(3000)
MsgBox(1,"ccc","ccc")
Sleep(3000)
 
Note that the above code has an error because missing parentheses. I need the autoit to ignore the error and exit. Help me.
 

Share this post


Link to post
Share on other sites



By ignore the error you mean not show the message box?

Look at the /ErrorStdout command line option for autoit. 

Share this post


Link to post
Share on other sites

When detecting the error the program will be terminated

Share this post


Link to post
Share on other sites

Have otherwise? without the prompt?

Share this post


Link to post
Share on other sites

francys,

Download and install the full SciTE4AutoIt3 package. Then when you run or compile a script, you automatically run a syntax checker which will pick up errors like this for you. That way you can correct them before you run the script live. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I do not want to fix the code. I want it to be finalized to find any errors.

Share this post


Link to post
Share on other sites

francys,

There is no tool that I know of that will correct the code for you. The tools to which I pointed you will tell that there is an error, what type it is, and where it is in the script - it is then up to you to fix it. After all, it is your code and so you made the error in the first place - so it seems only logical that you are the one to amend it to remove the error. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

And where's my jet-pack!

You can create a script to clean up/fix other scripts...seems like a lot of work though :)

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Because I have a script much bigger than this and sometimes it works correctly and sometimes the error, not the error code, but in other situations.
Continue studying. Thank you.

Share this post


Link to post
Share on other sites

francys,

So install the SciTE4AutoIt3 package and run the script from that - then you will be pointed to the very line that caused the problem. Good luck. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Sounds like syntax is good, if it can run.  You need to do error checking, and logging, to see excatly where logic is failing within the run.  That way, you can make the piece more fail-proof.

Without the actual error, or script, we can't help

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Correct me if I'm wrong, but I'm gong to attempt to rephrase what you are asking for since it is unclear.

Are you asking for a way to just have the application exit with no error message when you run in to a problem due to bad coding, like invalid dimensions of an array?

If you are asking for it to ignore the error and keep running, that's not going to be possible, as the error was script breaking.

As mentioned above, proper error checking is the right solution, but I'm curious as to exactly what you are looking for as the solution.

Share this post


Link to post
Share on other sites

Your first MsgBox is missing its last parenthesis...Said none of the above posters.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

the parenthesis is not the poster's real issue, blckpythn :)...the question for the missing parenthesis was rhetorical (at least from my interpretation, explained in post #11)

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Exactly danwilli
 
"a way to just have the application exit with no error message when you run in to a problem due to bad coding."
 
Thanks for your patience

Share this post


Link to post
Share on other sites

well, in his examples of bad subscripts in an array, do error checking like this, so that error does not occur:

$array = ""
For $i = 0 To UBound($array)-1
    ConsoleWrite("you wont see this, and no error, since I validated the array")
Next

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

 

Exactly danwilli
 
"a way to just have the application exit with no error message when you run in to a problem due to bad coding."
 
Thanks for your patience

 

 

The first reply to the question actually answers this.

By ignore the error you mean not show the message box?

Look at the /ErrorStdout command line option for autoit. 

To expand a little, Mat is saying to call your executable with the "/ErrorStdOut" parameter.

I'd bet you next question is if there is a way to force this option from in the script, and I'm not sure on that one, but Mat is correct in saying that this parameter will prevent the message box.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

took some debugging...if you compile your script with this, no message box will display

#include <Misc.au3>

If _Singleton("test",1) Then
    MsgBox(1,1,1) ; prove no blow up
    Run(@ScriptFullPath & " " & "/ErrorStdOut")
    Sleep(5000)
    Exit
EndIf
MsgBox(1,1,2) ; prove about to blow up
$array[20] ; this is invalid, and will blowup without the above

















this will work for exe or au3:

#include <Misc.au3>

$Autoit = @ProgramFilesDir & "\autoit3\autoit3.exe"
If StringRight(@ScriptName,3) = "au3" Then
    $runcommand = $Autoit & " /ErrorStdOut " & @ScriptFullPath
Else
    $runcommand = @ScriptFullPath & " " & "/ErrorStdOut"
EndIf

If _Singleton("test",1) Then
    MsgBox(1,1,1) ; prove no blow up
    Run($runcommand)
    Sleep(5000)
    Exit
EndIf

MsgBox(1,1,2) ; prove about to blow up
$array[20] ; this is invalid, and will blowup without the above



Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

took some debugging...if you compile your script with this, no message box will display

#include <Misc.au3>

If _Singleton("test",1) Then
    MsgBox(1,1,1) ; prove no blow up
    Run(@ScriptFullPath & " " & "/ErrorStdOut")
    Sleep(5000)
    Exit
EndIf
MsgBox(1,1,2) ; prove about to blow up
$array[20] ; this is invalid, and will blowup without the above

















this will work for exe or au3:

#include <Misc.au3>

$Autoit = @ProgramFilesDir & "\autoit3\autoit3.exe"
If StringRight(@ScriptName,3) = "au3" Then
    $runcommand = $Autoit & " /ErrorStdOut " & @ScriptFullPath
Else
    $runcommand = @ScriptFullPath & " " & "/ErrorStdOut"
EndIf

If _Singleton("test",1) Then
    MsgBox(1,1,1) ; prove no blow up
    Run($runcommand)
    Sleep(5000)
    Exit
EndIf

MsgBox(1,1,2) ; prove about to blow up
$array[20] ; this is invalid, and will blowup without the above



We all know that the real solution is to do proper error checking, but in regards to what the OP was looking for, this looks great, good work!

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