Sign in to follow this  
Followers 0
Penny

Can I run a stacktrace in AutoIt? How?

8 posts in this topic

#1 ·  Posted (edited)

http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace.aspx

I used these in C# to find out exactly where and why I was having a problem. The code I used (RunUO, in case anyone knows...) basically stacktraced if the script crashed, telling you the lines and successive calls that took you to crashing. for instance

called Init() on line 5
called ThisWillEventuallyCrashIt() on line 112
called ThisWillCrashIt() on line 321
div/0 on line 342

I hope someone understood what I want to do :D

Edit: For instance, this is the code I use to handle the errors myself

Func ErrorLog($msg)
    _FileWriteLog(@ScriptDir & "\error.log", $msg)
EndFunc

Func ErrorHandling()
    ConsoleWrite(@CRLF & '-- Handled Error: "' & $ErrorHandler.Description & '"')
    
    Dim $h = Hex($ErrorHandler.Number, 8)
    
    Dim $strMsg = "Error Number: 0x" & $h & @CRLF
    $strMsg &= "Description: " & $ErrorHandler.Description & @CRLF
    $strMsg &= "Script Line: " & $ErrorHandler.ScriptLine & @CRLF
    
    If $Script_DebugMode Then       
        ConsoleWrite(@CRLF & $strMsg)
    EndIf
    
    ErrorLog("0x" & $h & ": " & $ErrorHandler.Description)
    
    SetError(1)
    
    If $Script_onerror_Exit Then
        MsgBox(4096,"Critical Error",$strMsg & @CRLF & @CRLF & "Application terminated.")
        Exit
    EndIf
EndFunc

how would I add some beatiful StackTraces to that? is it even possible? =(

Thanks!!

Edited by Penny

Share this post


Link to post
Share on other sites



can anyone help me with this? thanks...

Share this post


Link to post
Share on other sites

how would I do that? sorry I'm new to autoit =(

Share this post


Link to post
Share on other sites

There is a nice graphical debugger available, that is somewhat like Visual Studio.

Check it out here: http://www.autoitscript.com/forum/index.php?showtopic=21834

Share this post


Link to post
Share on other sites

You will need to have the full version of SciTE4AtutoIt3:

http://www.autoitscript.com/autoit3/scite/downloads.shtml

"Lite" version that comes with the regular AutoIt install

Posted Image

full version

Posted Image

Yeah I had the lite version...

..wow, that way of tracing errors (commenting absolutely every function) is rather untraditional (specially since I had a timer flying around, haha) but it got me there, so.. Thank you very much :D

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