Jump to content

Recommended Posts

Posted

Perfect, i'm just waiting for this future improvement!

  On 10/19/2012 at 12:15 PM, 'JScript said:

Several improvements will be made in the UDF including line numbering!

Thanks for UDF!

Posted

What is the purpose of getting current script line (without the includes)?

If i am running the program as user, and it's crashed, it will show the full script source line number, so, for the developer (when the crash is reported via email) it's more than enough to find out where is the error.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

One more thing...

The error handler should work with non compiled scripts, to allow debugging before compiling.

Can be done using StdOutRead instead of hooking crash message box.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

@MrCreatoR

The includes are not supposed to have errors.

I suggest to add separate line number for includes.

Getting the full script line number is not efficient, you need to obfsucate it to get the right line number.

Br, FireFox.

Posted

@Mrcreator

Try this example (without compiling) using context menu in explorer window:

#include "_AutoItErrorTrap.au3"

; Default messages...
_AutoItErrorTrap()

_Example()

Func _Example()
    Local $iOption = MsgBox(262180, "Error detection test!", "Hi!" & @CRLF & @CRLF & "Let's try to catch the AutoIt error window?" & _
            @CRLF & @CRLF & "Answer [Yes] to generate an syntaxe error, [No] to exit...")
    Select
        Case $iOption = 6 ;Yes
            ; Sybtaxe error |LoL|!
            MsgBox(4096, "Erro!",)

        Case $iOption = 7 ;No
            Exit
    EndSelect
EndFunc   ;==>_Example
You will see that also works normally In the same way as compiled!

JS

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

  Reveal hidden contents

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Posted

  On 10/19/2012 at 4:45 PM, 'MrCreatoR said:

What is the purpose of getting current script line (without the includes)?

If i am running the program as user, and it's crashed, it will show the full script source line number, so, for the developer (when the crash is reported via email) it's more than enough to find out where is the error.

If I have this script

#include <WinApi.au3>

$var = _WinApi_Somefunc()

MsgBox(0,0,$var[4444444]); error here

When that crashes, it will not return line #3

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

  On 10/19/2012 at 4:57 PM, 'MrCreatoR said:

The error handler should work with non compiled scripts, to allow debugging before compiling.

Can be done using StdOutRead instead of hooking crash message box.

To use StdOutRead we have to have another executable to monitor the error window, and in my UDF is not necessary!

JS

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

  Reveal hidden contents

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Posted

  On 10/19/2012 at 5:04 PM, 'JScript said:

You will see that also works normally In the same way as compiled!

Yes, but what about running from SciTE?

  On 10/19/2012 at 5:05 PM, 'JohnOne said:

When that crashes, it will not return line #3

Right, then you can use obfuscator and find the line :). Perhaps the UDF could have _AutoItErrorDebug function, to do the obfuscator stuff (just combine together the includes).

  On 10/19/2012 at 5:07 PM, 'JScript said:

To use StdOutRead we have to have another executable to monitor the error window, and in my UDF is not necessary!

I am talking about reading the stream, not the window.

Anyway, the console output itself considered as a debug tool :), my mistake.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  On 10/19/2012 at 6:10 PM, 'MrCreatoR said:

Right, then you can use obfuscator and find the line :). Perhaps the UDF could have _AutoItErrorDebug function, to do the obfuscator stuff (just combine together the includes).

That's one way to do it, but I've never been able to accurately get it :(

But if the exact line number/au3file/function were to pop up in a box, well

that can't harm anyone really can it :)

I'm still a little worried about the trade off for large scripts though.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted (edited)

About show original line number in post by FireFox

The same file with a few modifications:

ShowOriginalLineNumbers.au3 *New:

Compiled:

  Reveal hidden contents

Posted Image

Non compiled:

  Reveal hidden contents

Posted Image

Final structure of the example file:

Global $__iLineNumber=0
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_AU3Check=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "_AutoItErrorTrap.au3"

;If Not @Compiled Then
;    MsgBox(4096, "Note:", "You need to compile first!")
;    Exit
;EndIf

; Default messages...
$__iLineNumber=14
_AutoItErrorTrap()

$__iLineNumber=16
_Example()

$__iLineNumber=18 & " - " & "Func _Example()"
Func _Example()
    $__iLineNumber=19 & " - " & "Func _Example()"
    Local $asArray[4] = ["JScript", "Jonatas", "AutoIt", "Brasil"]
    $__iLineNumber=20 & " - " & "Func _Example()"
    Local $iOption = MsgBox(262180, "Error detection test!", "Hi!" & @CRLF & @CRLF & "Let's try to catch the AutoIt error window?" & _
            @CRLF & @CRLF & "Answer [Yes] to generate an array error, [No] to exit...")
    $__iLineNumber=22 & " - " & "Func _Example()"
    Select
        $__iLineNumber=23 & " - " & "Func _Example()"
        Case $iOption = 6 ;Yes
            ; Error in array value!
            $__iLineNumber=25 & " - " & "Func _Example()"
            MsgBox(4096, "Erro!", $asArray[5])

        $__iLineNumber=27 & " - " & "Func _Example()"
        Case $iOption = 7 ;No
            $__iLineNumber=28 & " - " & "Func _Example()"
            Exit
    $__iLineNumber=29 & " - " & "Func _Example()"
    EndSelect
$__iLineNumber=30 & " - " & "Func _Example()"
EndFunc   ;==>_Example

Any suggestions to add?

JS

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

  Reveal hidden contents

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Posted

Once again, very nice !

You should add more statements to skip, like end statements (EndSelect/EndSwitch, EndIf, Next, WEnd, ...), also some things detected by Au3Check.

You can suggest the user to choose the error level reporter like in php. (more the level is low, and less you write line numbers)

Anyway, better GUI; keep it up :)

Posted (edited)

Thanks a lot, very good. I agree with the request from firefox.

The button submit doesn't work? Why don't disable it?

I'm curious, what is "Last screen" seen in your latest images attached?

Edit : find below which information are important to fix a bug in a application. Of course, it's my opinion. Feel free to use what you want!

  Reveal hidden contents

Edited by ricky03
Posted

@FireFox

Done:

#include <File.au3>

Local $sScriptPath = FileOpenDialog("select au3", @ScriptDir, "AutoIt3 Script (*.au3)", 3)
If @error Then Exit -1
If FileExists($sScriptPath & "_Debug.au3") Then
    FileDelete($sScriptPath & "_Debug.au3")
EndIf

Local $aLines, $sOutPut = "Global $__iLineNumber=0" & @CRLF
Local $blSkipNextLine = False
Local $iLine = 1, $sCurrentLine, $sFunc = "", $sIndent = ""

_FileReadToArray($sScriptPath, $aLines)

While $iLine <= $aLines[0]
    $sCurrentLine = $aLines[$iLine]
    $sLineStripWS = StringStripWS($aLines[$iLine], 3)

    If StringInStr($sLineStripWS, "EndFunc", 0, 1, 1, 7) Then
        $sFunc = ""
    EndIf

    If StringInStr($sLineStripWS, "#", 0, 1, 1, 1) Or StringInStr($sLineStripWS, ";", 0, 1, 1, 1) Or _
        StringInStr($sLineStripWS, "Select", 0, 1, 1, 6) Or StringInStr($sLineStripWS, "Switch", 0, 1, 1, 6) Or _
        StringInStr($sLineStripWS, "EndSelect", 0, 1, 1, 9) Or StringInStr($sLineStripWS, "EndSwitch", 0, 1, 1, 9) Or _
        StringInStr($sLineStripWS, "EndIf", 0, 1, 1, 5) Or StringInStr($sLineStripWS, "Next", 0, 1, 1, 4) Or _
        StringInStr($sLineStripWS, "WEnd", 0, 1, 1, 4) Or StringInStr($sLineStripWS, "Exit", 0, 1, 1, 4) Or _
        StringInStr($sLineStripWS, "EndFunc", 0, 1, 1, 7) Or StringLen($sLineStripWS) = 0 Then
        $sOutPut &= $sCurrentLine & @CRLF
        $iLine += 1
        ContinueLoop
    EndIf

    If StringInStr($sLineStripWS, "Func", 0, 1, 1, 4) Then
        $sFunc = $sCurrentLine
    EndIf

    If $blSkipNextLine Then
        $blSkipNextLine = False
    Else
        $sIndent = ""
        While StringIsSpace(StringLeft($sCurrentLine, StringLen($sIndent) + 1))
            $sIndent = StringLeft($sCurrentLine, StringLen($sIndent) + 1)
        WEnd
        ;$sOutPut &= "$__iLineNumber=" & $iLine & " & ': " & StringReplace($sCurrentLine, "'", '"') & "'" & @CRLF
        ;If $sFunc Then
            ;$sOutPut &= $sIndent & "$__iLineNumber=" & $iLine & ' & " - " & "' & $sFunc & '"' & @CRLF
            $sOutPut &= $sIndent & "$__iLineNumber=" & $iLine & ' & " - " & ' & "'" & _TruncatePath(StringReplace($sLineStripWS, "'", '"'), 300) & "'" & @CRLF
        ;Else
        ;    $sOutPut &= $sIndent & "$__iLineNumber=" & $iLine & @CRLF
        ;EndIf
    EndIf

    $sOutPut &= $sCurrentLine & @CRLF

    If StringRight($sCurrentLine, 2) = " _" Then
        $blSkipNextLine = True
    EndIf

    $iLine += 1
WEnd

FileWrite($sScriptPath & "_Debug.au3", $sOutPut)

Func _TruncatePath($sPath, $iValue)
    Local $sRet = DllCall("Shlwapi.dll", "BOOL", "PathCompactPath", "int", 0, "str", $sPath, "uint", $iValue)
    Return $sRet[2]
EndFunc   ;==>_TruncatePath

I added the following line to have at least the first 300 characters corresponding to the original line of the program!

_TruncatePath(StringReplace($sLineStripWS, "'", '"'), 300)

The result is this:

  Reveal hidden contents

Posted Image

  On 10/23/2012 at 8:49 AM, 'ricky03 said:

The button submit doesn't work? Why don't disable it?

Have patience, is still in progress...

  On 10/23/2012 at 8:49 AM, 'ricky03 said:

I'm curious, what is "Last screen" seen in your latest images attached?

Are more new stuff, wait!

  On 10/23/2012 at 8:49 AM, 'ricky03 said:

Edit : find below which information are important to fix a bug in a application. Of course, it's my opinion. Feel free to use what you want!

Thank you!

JS

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

  Reveal hidden contents

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Posted (edited)

Fixes:

  • 0.10.2312.2600b
  • 23/10/2012 -> *Added support to display the original line numbers in the scripts compiled! Thanks to @FireFox for this tip!

    $hAET_GETERROR = StringRegExpReplace($hAET_GETERROR, "d+[0-9]", Eval("__iLineNumber") & @CRLF)

    *Additional information suggested by @ricky03, thank you!

    *Some bugs were fixed...

    The file ShowOriginalLineNumbers.au3 was added in zip file.

Reagrds,

João Carlos.

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

  Reveal hidden contents

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Posted

Hello,

new idea for new feature, on your ShowOriginalLineNumbers modify also our included files with the lines, but only for example the functions to don't increase a lot of lines?

Thanks again!

Posted

  On 10/25/2012 at 7:34 AM, 'ricky03 said:

on your ShowOriginalLineNumbers modify also our included files with the lines

In this case it would be better to create a new folder with the script files, BUT if you have external files (images, dlls) it's a problem.

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
×
×
  • Create New...