macost Posted October 2, 2007 Posted October 2, 2007 Dear all, I´m needing to use the function "Try Except" because I don´t want to stop my program if a error occurs. But i didn´t find this function in the Help, Forum... anyone knows something about it? Thanks in advanced. Maycon Costa
Richard Robertson Posted October 2, 2007 Posted October 2, 2007 Wrong forum. What does the Try Except do? Is it an error catching clause? If you are using AutoIt, catch errors by checking the @error value. If you are using Delphi with AutoItX, I really have no idea what you are asking.
martin Posted October 2, 2007 Posted October 2, 2007 macost said: Dear all,I´m needing to use the function "Try Except" because I don´t want to stop my program if a error occurs. But i didn´t find this function in the Help, Forum... anyone knows something about it?Thanks in advanced.Maycon CostaI use Try/Except in Delphi but have never missed it in AutoIt. Can you give an example of where you think you would need it in an AutoIt script? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
macost Posted October 2, 2007 Author Posted October 2, 2007 Hello, I´m looking for a similar function of Try Except in AutoIT. Here´s a sample of the code (Delphi): try WinExec('c:\program.exe'); except ShowMessage(' ERROR' ); end; I need to use one cod equal in Auto It. tks
MadBoy Posted October 2, 2007 Posted October 2, 2007 macost said: Hello, I´m looking for a similar function of Try Except in AutoIT. Here´s a sample of the code (Delphi): try WinExec('c:\program.exe'); except ShowMessage(' ERROR' ); end; I need to use one cod equal in Auto It. tks Do something like $string = Run(...) If $string = ... Then .... Else ; do something else EndIf My little company: Evotec (PL version: Evotec)
Zedna Posted October 2, 2007 Posted October 2, 2007 Note: _GetLastErrorMessage is not neccessary just for exact error message Opt("RunErrorsFatal", 0) Run('calc2.exe') If @error Then MsgBox(16, "Error", "Run() produced and error:" & @CRLF & _GetLastErrorMessage ()) Func _GetLastErrorMessage($DisplayMsgBox="") Local $ret,$s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll","int","GetLastError") $ret = DllCall("kernel32.dll","int","FormatMessage", _ "int",$FORMAT_MESSAGE_FROM_SYSTEM, _ "ptr",0, _ "int",$ret[0], _ "int",0, _ "ptr",DllStructGetPtr($p), _ "int",4096, _ "ptr",0) $s = DllStructGetData($p,1) $p = 0 If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $s) return $s EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search
martin Posted October 2, 2007 Posted October 2, 2007 (edited) Zedna said: Note: _GetLastErrorMessage is not neccessary just for exact error message Opt("RunErrorsFatal", 0) Run('calc2.exe') If @error Then MsgBox(16, "Error", "Run() produced and error:" & @CRLF & _GetLastErrorMessage ()) Func _GetLastErrorMessage($DisplayMsgBox="") Local $ret,$s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll","int","GetLastError") $ret = DllCall("kernel32.dll","int","FormatMessage", _ "int",$FORMAT_MESSAGE_FROM_SYSTEM, _ "ptr",0, _ "int",$ret[0], _ "int",0, _ "ptr",DllStructGetPtr($p), _ "int",4096, _ "ptr",0) $s = DllStructGetData($p,1) $p = 0 If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $s) return $s EndFunc Happy birthday Zedna Edited October 2, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Zedna Posted October 2, 2007 Posted October 2, 2007 martin said: Happy birthday Zedna Thanks martin Resources UDF ResourcesEx UDF AutoIt Forum Search
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now