Jump to content

Recommended Posts

Posted (edited)

Hi all

Not sure if this any help to anyone but i modified the _AutoItErrorTrap.au3 file to support sending reports through Zapier to my e-mail address.

To do this though i removed the memory, IO and OS details from the report so it was just Module, Environment and the Error details. The code probably isnt perfect but it seems to work to send them:

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "WEB HOOK URL FROM ZAPIER HERE", False)
$oHTTPSub = _GUICtrlEdit_GetText($hAET_SND_EDIT1)
$oHTTPBod = _GUICtrlEdit_GetText($hAET_SND_EDIT2)
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send('Sub=' & $oHTTPSub & Chr(38) & 'Bod=' & $oHTTPBod)
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
If $oStatusCode == 200 Then
    ; Message sent just output the response
    Sleep(1000)
    MsgBox(262208, "Report Sent", "Your bug report has been sent to the developer")
Else
    ; Error
    MsgBox(0, "", "Error sending message")
EndIf

However i am having some trouble with compiling my program with this error trapping added to it. When i tell the program to compile from Scite it starts to go through the UDF includes i have and gets to resources.au3 (in my case) and then just hangs for a very long time there before i eventually cancel it.

Should i be running the ShowOriginalLine.exe (from the download) on the obfuscated source or the original source? If it can be either then what effect would that have to line numbers etc? Also is there any way to see what is causing it to slow/hang on that file?

Thanks

Adam

** Update **

Managed to get this working again, think the problem was caused by the resources.au3 file in combination with the AutoItErrorTrap.au3 file as resources.au3 has some constants set manually in its file whereas errortrap.au3 calls the APIConstants.au3 file so i was getting multiple declare call problems. I commented out the ones in resources.au3 and it compiles if i turn off warnings in AU3Check (getting possibly used before declaration calls now, guessing i just need to call the errortrap.au3 before the resources.au3 file to solve that?)

It is having problems reading a couple of my own function files in though, getting "Error reading file to Array! - Error number 2" for 2 of the files out of 6

** Update 2 **

Actually i think the error is because those files are both empty place holder files at the moment so there is nothing to read for them. Also commenting out the constants in resources.au3 and moving the errortrap.au3 before it seems to have solved the problem with the used before declaration calls

Edited by DOTCOMmunications
  • 3 months later...
Posted

It only works with the beta version of autoit .

It should work also with the stable autoit version?
 
Please help me.
I want to use it in the
stable version!
Posted

ShowOriginalLine.exe insert a not accurate line number.

Original:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_Run_Obfuscator=y
#AutoIt3Wrapper_Icon=myicon.ico
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=(c) me
#AutoIt3Wrapper_Res_SaveSource=n
#obfuscator_Ignore_Funcs=Callback
#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...
_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

 

After using ShowOriginalLine.exe :

Global $__iLineNumber=0
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_Run_Obfuscator=y
#AutoIt3Wrapper_Icon=myicon.ico
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=(c) me
#AutoIt3Wrapper_Res_SaveSource=n
#obfuscator_Ignore_Funcs=Callback
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "_AutoItErrorTrap.au3"

$__iLineNumber=14 & ' - If Not @Compiled Then•'
If Not @Compiled Then
    $__iLineNumber=15 & ' - MsgBox(4096, "Note:", "You need to compile first!")•'
    MsgBox(4096, "Note:", "You need to compile first!")
    Exit
EndIf

; Default messages...
$__iLineNumber=20 & ' - _AutoItErrorTrap()•'
_AutoItErrorTrap()

$__iLineNumber=22 & ' - _Example()•'
_Example()

$__iLineNumber=24 & ' - Func _Example()•'
Func _Example()
    $__iLineNumber=25 & ' - Local $iOption = MsgBox(262180, "Error detection test!", "Hi ...•'
    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...")
    $__iLineNumber=28 & ' - Case $iOption = 6 ;Yes•'
    Select
        Case $iOption = 6 ;Yes
            ; Sybtaxe error |LoL|!
            $__iLineNumber=30 & ' - MsgBox(4096, "Erro!",)•'
            MsgBox(4096, "Erro!",)

        $__iLineNumber=32 & ' - Case $iOption = 7 ;No•'
        Case $iOption = 7 ;No
            Exit
    EndSelect
EndFunc   ;==>_Example

 

The $__iLineNumber is reporting a wrong line number

Posted

Hi!

I compiled and run the code, there was no error in line number information, see:

4QR7d2A.png

For convenience, use the following directives:

#AutoIt3Wrapper_Run_Before=ShowOriginalLine.exe %in%
#AutoIt3Wrapper_Run_After=ShowOriginalLine.exe %in%

Note: Supposing that the program ShowOriginalLine.exe is in the same folder!

Regards,

JS

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

Somewhere Out ThereJames Ingram

somewh10.png

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

Posted

JScript,

First of all, please allow me to say "thank you, thank you, thank you" for this wonderful script :)

Second, I'm sorry, I was wrong :( the line number is correct!

After few hours of testing, I need to report/asking about this:

I tested it on one of my large scripts (4000++ lines), I call it this way:

_AutoItErrorTrap("aa","bb",False)

 

It's called with argument "False" because if I call it with "True", when exit the script, it will throw an error (crash).

If I add some lines in purpose to try the error capture eg: MsgBox(4096, "Erro!",)

it will capture an error, BUT not that error. The error it reported is random, like this:

C:UsersWindowsDropboxmyfile.exe (4474 - Return $GUI_RUNDEFMSG
Module: Main/
: ==> Error parsing function call.:
 

The line is correct (line 4473 is "Return $GUI_RUNDEFMSG").

On another occasions, it will report an error on different line.

The reported line/error is incorrect, because it should be no error and if I comment _AutoItErrorTrap("aa","bb",False)

it will run smooth.

Any idea how to solve this? I'm really keen to use this script on all of my scripts.

Thanks :)

Posted

My issue with this UDF is still remain the same:

If called without paramater:

_AutoItErrorTrap()

 

It will throw an error when exit

but if called with parameter:

_AutoItErrorTrap("aa","bb",False)

 

it will report random errors (that is incorrect) because there is no error for that particular line.

After few days I still cant find solution for this :(

Posted

Hello!
I have the wont to do a large program into separate modules and with it besides being easier code maintenance, I never had problems with this UDF realatados incorrectly!

But I'll do some tests to verify that the reported ok?

Regards,

JS

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

Somewhere Out ThereJames Ingram

somewh10.png

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

Posted

Hello!

I have the wont to do a large program into separate modules and with it besides being easier code maintenance, I never had problems with this UDF realatados incorrectly!

But I'll do some tests to verify that the reported ok?

Regards,

JS

 

Thank you, JS.

Meanwhile I will also do some tests on another scripts.

Thanks, again :)

  • 2 months later...
Posted (edited)

i highly recommend you to add some check like this:

If $ErrorAlreadyOccurred = True Then Return

at the top of the __CBTProc_ErrorTrap($nCode, $wParam, $lParam).

and you also need to define this variable to True when the first error occurred.

it will solve you a bug in case that there is a error in the ErrorTrap function.

Edited by Guest
Posted (edited)

Updated the ShowOriginalLine program to better support module names.
 
You can leave it blank, enter a custom name, or use @FILE to use the name of the file(without extension)
 
Simply run this on any includes that are in your script, and you will be able to indentify which include the error came from, with accurate line numbers.
(Update: Now automatically runs itself on includes, and automatically captures their name.)
 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=.\Resources\Icon\Icon1.ico
#AutoIt3Wrapper_Outfile=ShowOriginalLine.exe
#AutoIt3Wrapper_Compression=0
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY
#AutoIt3Wrapper_Res_Description=Show original line number in AutoItErrorTrap.
#AutoIt3Wrapper_Res_Fileversion=0.11.1512.2600
#AutoIt3Wrapper_Res_ProductVersion=0.11.1512.2600
#AutoIt3Wrapper_Res_LegalCopyright=(C) FireFox and João Carlos (JScript)
://////=__=-
://////=__=.=
://////=__=
://////=__=.,://///= their respective owners. - All rights reserved.
://////=__=.=
://////=__=
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#AutoIt3Wrapper_Run_After="%scitedir%\AutoIt3Wrapper\ResHacker.exe" -delete %out%, %out%, MENU,,
#AutoIt3Wrapper_Run_After="%scitedir%\AutoIt3Wrapper\ResHacker.exe" -delete %out%, %out%, DIALOG,,
#AutoIt3Wrapper_Run_After="%scitedir%\AutoIt3Wrapper\ResHacker.exe" -delete %out%, %out%, ICONGROUP,162,
#AutoIt3Wrapper_Run_After="%scitedir%\AutoIt3Wrapper\ResHacker.exe" -delete %out%, %out%, ICONGROUP,164,
#AutoIt3Wrapper_Run_After="%scitedir%\AutoIt3Wrapper\ResHacker.exe" -delete %out%, %out%, ICONGROUP,169,
#AutoIt3Wrapper_Run_After="%autoitdir%\Aut2Exe\upx.exe" .\ShowOriginalLine.exe
#Obfuscator_Parameters=/striponly
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; #INDEX# =======================================================================================================================
; Title .........: ShowOriginalLine
; Module ........: Main
; Author ........: FireFox and João Carlos (JScript)
; Support .......:
; Version .......: 0.12.2112.2600
; AutoIt Version.: 3.3.8.1++
; Language ......: ->
; Description ...: Show non compiled line number!
; Free Software .: Redistribute and change under these terms:
;               This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
;       as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
;
;               This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
;       of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
;
;               You should have received a copy of the GNU General Public License along with this program.
;               If not, see <http://www.gnu.org/licenses/>.
; ===============================================================================================================================

#region AutoIt3Wrapper directives section
;** AUT2EXE settings
; ================================================================================================================================================
;** Target program Resource info
;#AutoIt3Wrapper_Res_Language=1046                                      ;Resource Language code . default 2057=English (United Kingdom)
;#AutoIt3Wrapper_Res_Field=CompanyName|
; ================================================================================================================================================
; AU3Check settings
;#AutoIt3Wrapper_Run_AU3Check=                          ;(Y/N) Run au3check before compilation. Default=Y
;#AutoIt3Wrapper_AU3Check_Stop_OnWarning=               ;(Y/N) N=Continue on Warnings.(Default) Y=Always stop on Warnings
; Obfuscator =====================================================================================================================================
; ================================================================================================================================================
; RUN BEFORE AND AFTER definitions
; ================================================================================================================================================
#endregion AutoIt3Wrapper directives section
Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand

#include <File.au3>
#include <String.au3>

#Tidy_Off
; #VARIABLES# ===================================================================================================================
Local $sScriptPath
Local $aLines
Local $iLine = 1
Local $sLineStripWS
Local $sInclude = ""
Local $sComment = 0
Global $sOutPut = ""
; Cmd line
Global $iSkipAllVars = 0, $iSkipGlobalVars = 0, $iSkipLocalVars = 0, $iOnlyFuncNames = 0, $iShowLinePreview = 1, $iPrevLenght = 60
;----> Word list to skip line, fell free to add more!
Global $asWordList = "#|;|Case Else|Else|End|Continue|Exit|Do|Next|WEnd|Exit|Break|Opt|AutoIt|BlockInput|OnAutoItExit|Sleep|Send|Set"
$asWordList = StringSplit($asWordList, "|")
;<----
; ================================================================================================================================
#Tidy_On

Select
    Case Not $CmdLine[0]
        $sScriptPath = FileOpenDialog("Select an au3 file...", @ScriptDir, "AutoIt3 v3 Script (*.au3)", 3)
        If @error Then Exit 0
        $module = InputBox("Module Name", "Module Name (Leave Blank For Main Script)", "")

    Case Else
        $sScriptPath = $CmdLineRaw
        If Not FileExists($sScriptPath) Then Exit -1
        $module = '@FILE'
EndSelect

If Not _FileReadToArray($sScriptPath, $aLines) Then
    If Not $CmdLine[0] Then Exit -2
    MsgBox(4096, "ShowOriginalLine", "Error reading file to Array!" & @CRLF & "Error number: " & @error)
    Exit
EndIf

; Search for local includes and #ShowOriginalLine_Param!
Local $asSplit, $aiSplit
While $iLine <= $aLines[0]
    $sLineStripWS = StringStripWS($aLines[$iLine], 8)
    If StringInStr($sLineStripWS, "#ShowLine_Off", 0, 1, 1, 13) Then
        While $iLine <= $aLines[0]
            If StringInStr($sLineStripWS, "#ShowLine_On", 0, 1, 1, 12) Then
                ExitLoop
            EndIf
            $iLine += 1
            $sLineStripWS = StringStripWS($aLines[$iLine], 3)
        WEnd
        $iLine += 1
        ContinueLoop
    EndIf

    If StringInStr($sLineStripWS, "#ShowOriginalLine_Param", 0, 1, 1, 23) Then
        $asSplit = StringSplit(StringLower($sLineStripWS), "/")
        For $i = 2 To $asSplit[0]
            Switch $asSplit[$i]
                Case "sv", "skipallvars"
                    $iSkipAllVars = 1
                Case "sg", "skipglobalvars"
                    $iSkipGlobalVars = 1
                Case "sl", "skiplocalvars"
                    $iSkipLocalVars = 1
                Case "ofn", "onlyfuncnames"
                    $iOnlyFuncNames = 1
                Case "slp", "skiplinepreview"
                    $iShowLinePreview = 0
                Case Else
                    $aiSplit = StringSplit($asSplit[$i], "=")
                    If Not @error Then
                        For $j = 1 To $aiSplit[0]
                            Switch $aiSplit[$j]
                                Case "lpl", "linepreviewlenght"
                                    $iPrevLenght = Number($aiSplit[$j + 1])
                            EndSwitch
                        Next
                    EndIf
            EndSwitch
        Next
    EndIf

    If StringInStr($sLineStripWS, '#include"', 0, 1, 1, 9) Then
        $sInclude = _StringBetween($sLineStripWS, '"', '"')
        If Not @error Then
            $sInclude = $sInclude[0]
            If Not StringInStr($sInclude, "_AutoItErrorTrap.au3") Then
                If StringInStr($sInclude, ".\") Then
                    $sInclude = StringReplace($sInclude, ".\", @ScriptDir & "\")
                EndIf
                If FileExists($sInclude) Then
                    $sOutPut = "$__iLineNumber=0" & @CRLF
                    _AddLineIndex($sInclude, 0, StringTrimRight(StringReplace($sInclude,"\","/"), 4))
                EndIf
            EndIf
        EndIf


    EndIf
    $iLine += 1
WEnd

$sOutPut = "Global $__iLineNumber=0" & @CRLF
_AddLineIndex($sScriptPath, $aLines, $module)

; #FUNCTION# ====================================================================================================================
; Name ..........: _AddLineIndex
; Description ...:
; Syntax ........: _AddLineIndex()
; Parameters ....:
; Return values .: None
; Author ........: JScript
; Modified ......:
; Remarks .......:  Detecting AutoIt statement continuation by @Varian
;                   Link: http://www.autoitscript.com/forum/topic/145482-question-about-regex/#entry1028087
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _AddLineIndex($sScriptPath, $aLines = 0, $module='@FILE')
    if $module = '@FILE' Then
    $filename = StringSplit(_ArrayToString(StringRegExp($sScriptPath, "(.*?)\.", 1), ''), "\")
    $module = $filename[$filename[0]]
    EndIf
    Local $iLine = 1, $iPrevious = 0, $sCurrentLine, $sLineStripWS, $sIndent = "", $sSelect = 0, $sSwitch = 0
    Local $fMainFile = True, $hFileOpen, $hFileWrite, $iError = 0, $sModule = "•"&$module, $sPrgName, $sSpace

    If Not IsArray($aLines) Then
        If Not _FileReadToArray($sScriptPath, $aLines) Then
            $iError = @error
            If Not $CmdLine[0] Then Return SetError(-2, 0, 0)
            MsgBox(4096, "ShowOriginalLine", "Error reading file to Array!" & @CRLF & "Error number: " & $iError & @CRLF & "File: " & $sScriptPath)
            Return SetError(-2, 0, 0)
        EndIf
        ConsoleWrite($sModule & @CRLF)
        $fMainFile = False
    EndIf

    Select
        Case StringInStr($aLines[1], "$__iLineNumber")
            $iLine = 2
            $sOutPut = ""
            While $iLine <= $aLines[0]
                $sCurrentLine = $aLines[$iLine]
                $sLineStripWS = StringStripWS($aLines[$iLine], 3)

                If Not $sLineStripWS Then
                    $sOutPut &= $sCurrentLine & @CRLF
                    $iLine += 1
                    ContinueLoop
                EndIf

                If StringMid($sLineStripWS, 1, 14) = "$__iLineNumber" Then
                    $iLine += 1
                    ContinueLoop
                EndIf

                $sOutPut &= $sCurrentLine & @CRLF
                $iLine += 1
            WEnd

        Case Else
            ; backup!!!
            FileCopy($sScriptPath, $sScriptPath & ".Backup.au3")

            If $iOnlyFuncNames Then
                $sOutPut &= "$__iLineNumber=0" & " & '$sModule$'" & @CRLF
            EndIf

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

                If $aLines[$iLine] = "" Then
                    $sOutPut &= $sCurrentLine & @CRLF
                    $iLine += 1
                    ContinueLoop
                EndIf

                If _SkipLineByWord($sLineStripWS) Then
                    $sOutPut &= $sCurrentLine & @CRLF
                    $iLine += 1
                    ContinueLoop
                EndIf

                $sIndent = ""
                $sSpace = StringLeft($sCurrentLine, StringLen($sIndent) + 1)
                While StringIsSpace($sSpace)
                    $sIndent = $sSpace
                    $sSpace = StringLeft($sCurrentLine, StringLen($sIndent) + 1)
                WEnd

                If $iOnlyFuncNames Then
                    $sOutPut &= $sCurrentLine & @CRLF
                    If StringInStr($sLineStripWS, "Func", 0, 1, 1, 4) Then
                        $sOutPut &= $sIndent & "$__iLineNumber=" & $iLine
                        If $iShowLinePreview Then
                            $sOutPut &= " & ' - " & _StringTruncate(StringReplace($sLineStripWS, "'", '"'), $iPrevLenght) & "$sModule$'" & @CRLF
                        Else
                            $sOutPut &= " & '$sModule$'" & @CRLF
                        EndIf
                    EndIf
                    $iLine += 1
                    ContinueLoop
                EndIf

                ; Skip comment group by: #comments-start or #cs
                If StringRegExp($sLineStripWS, "\A(?i)#cs\b") Or StringRegExp($sLineStripWS, "\A(?i)#comments-start\b") Then
                    $iLine += 1
                    While $iLine <= $aLines[0]
                        $sCurrentLine = $aLines[$iLine]
                        $sLineStripWS = StringStripWS($sCurrentLine, 3)
                        If StringRegExp($sLineStripWS, "\A(?i)#ce\b") Or StringRegExp($sLineStripWS, "\A(?i)#comments-end\b") Then
                            $sOutPut &= $sCurrentLine & @CRLF
                            ExitLoop
                        EndIf
                        $sOutPut &= $sCurrentLine & @CRLF
                        $iLine += 1
                    WEnd
                    ContinueLoop
                EndIf

                If StringInStr($sLineStripWS, "#ShowLine_Off", 0, 1, 1, 13) Then
                    $iLine += 1
                    While $iLine <= $aLines[0]
                        $sCurrentLine = $aLines[$iLine]
                        $sLineStripWS = StringStripWS($sCurrentLine, 3)
                        If StringInStr($sLineStripWS, "#ShowLine_On", 0, 1, 1, 12) Then
                            $sOutPut &= $sCurrentLine & @CRLF
                            ExitLoop
                        EndIf
                        $sOutPut &= $sCurrentLine & @CRLF
                        $iLine += 1
                    WEnd
                    ContinueLoop
                EndIf

                ; #ShowOriginalLine_Param
                Select
                    Case $iSkipAllVars
                        If StringInStr($sLineStripWS, "Global", 0, 1, 1, 6) Or StringInStr($sLineStripWS, "Local", 0, 1, 1, 5) Then
                            $sOutPut &= $sCurrentLine & @CRLF
                            $iLine += 1
                            ContinueLoop
                        EndIf
                    Case $iSkipGlobalVars
                        If StringInStr($sLineStripWS, "Global", 0, 1, 1, 6) Then
                            $sOutPut &= $sCurrentLine & @CRLF
                            $iLine += 1
                            ContinueLoop
                        EndIf
                    Case $iSkipLocalVars
                        If StringInStr($sLineStripWS, "Local", 0, 1, 1, 5) Then
                            $sOutPut &= $sCurrentLine & @CRLF
                            $iLine += 1
                            ContinueLoop
                        EndIf
                EndSelect

                ;Select|Switch
                $sSelect = StringInStr($sLineStripWS, "Select", 0, 1, 1, 6)
                $sSwitch = StringInStr($sLineStripWS, "Switch", 0, 1, 1, 6)
                If $sSelect Or $sSwitch Then
                    If $sSwitch Then
                        $sOutPut &= $sIndent & "$__iLineNumber=" & $iLine
                        If $iShowLinePreview Then
                            $sOutPut &= " & ' - " & _StringTruncate(StringReplace($sLineStripWS, "'", '"'), $iPrevLenght) & "$sModule$'" & @CRLF
                        Else
                            $sOutPut &= " & '$sModule$'" & @CRLF
                        EndIf
                    EndIf

                    $iPrevious = $iLine ; save
                    $iLine += 1
                    While $iLine <= $aLines[0]
                        $sLineStripWS = StringStripWS($aLines[$iLine], 3)
                        If Not StringInStr($sLineStripWS, "Case", 0, 1, 1, 4) Then
                            $iLine += 1
                            ContinueLoop
                        EndIf
                        ExitLoop
                    WEnd

                    $sOutPut &= $sIndent & "$__iLineNumber=" & $iLine
                    If $iShowLinePreview Then
                        $sOutPut &= " & ' - " & _StringTruncate(StringReplace($sLineStripWS, "'", '"'), $iPrevLenght) & "$sModule$'" & @CRLF
                    Else
                        $sOutPut &= " & '$sModule$'" & @CRLF
                    EndIf

                    $sOutPut &= $sCurrentLine & @CRLF

                    $iLine = $iPrevious ; restore
                    $iLine += 1
                    ContinueLoop
                EndIf

                If $iPrevious Then
                    $iPrevious = 0
                Else
                    $sOutPut &= $sIndent & "$__iLineNumber=" & $iLine
                    If $iShowLinePreview Then
                        $sOutPut &= " & ' - " & _StringTruncate(StringReplace($sLineStripWS, "'", '"'), $iPrevLenght) & "$sModule$'" & @CRLF
                    Else
                        $sOutPut &= " & '$sModule$'" & @CRLF
                    EndIf
                EndIf
                $sOutPut &= $sCurrentLine & @CRLF

                ;----> Detecting AutoIt statement continuation
                ; by @Varian at http://www.autoitscript.com/forum/topic/145482-question-about-regex/#entry1028087
                If StringRegExp($sCurrentLine, "(?m)(^.*_)(?:\s*$|\s*;.*\s*$)", 0) Then
                    $iLine += 1
                    While $iLine <= $aLines[0]
                        $sCurrentLine = $aLines[$iLine]
                        If Not StringRegExp($sCurrentLine, "(?m)(^.*_)(?:\s*$|\s*;.*\s*$)", 0) Then
                            $sOutPut &= $sCurrentLine & @CRLF
                            ExitLoop
                        EndIf
                        $sOutPut &= $sCurrentLine & @CRLF
                        $iLine += 1
                    WEnd
                EndIf
                ;<----

                $iLine += 1
            WEnd
    EndSelect

    $hFileOpen = FileOpen($sScriptPath, 2)
    If $hFileOpen = -1 Then
        MsgBox(4096, "ShowOriginalLine", "Error: Unable to open file!" & @CRLF & "File: " & $sScriptPath)
        Return SetError(-3, 0, 0)
    EndIf
    $hFileWrite = FileWrite($hFileOpen, $sOutPut)
    FileClose($hFileOpen)

    If $hFileWrite Then
        If Not $CmdLine[0] And $fMainFile Then MsgBox(4096, "ShowOriginalLine", "Info: The file was successfully modified!" & @CRLF & @CRLF & _
                "It was made a backup using the name: " & @CRLF & $sScriptPath & ".Backup.au3")
    Else
        If Not $CmdLine[0] Then MsgBox(4096, "ShowOriginalLine", "Error: The file not opened in writemode or file is read only!" & @CRLF & "File: " & $sScriptPath)
        Return SetError(-3, 0, 0)
    EndIf
    Return SetError(0, 0, 1)
EndFunc   ;==>_AddLineIndex

; #FUNCTION# ====================================================================================================================
; Name ..........: _SkipLineByWord
; Description ...:
; Syntax ........: _SkipLineByWord($sLine)
; Parameters ....: $sLine               - A string value.
; Return values .: None
; Author ........: JScript
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SkipLineByWord($sLine)
    Local $ilen

    For $i = 1 To $asWordList[0]
        $ilen = StringLen($asWordList[$i])
        If StringInStr($sLine, $asWordList[$i], 0, 1, 1, $ilen) Then
            Return 1
        EndIf
    Next
    Return 0
EndFunc   ;==>_SkipLineByWord

; #FUNCTION# ====================================================================================================================
; Name ..........: _StringTruncate
; Description ...:
; Syntax ........: _StringTruncate($sString, $iValue)
; Parameters ....: $sString             - A string value.
;                  $iValue              - An integer value.
; Return values .: None
; Author ........: JScript
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _StringTruncate($sString, $iValue)
    Local $sRet

    $sRet = StringLeft($sString, $iValue)
    If StringLen($sString) > $iValue Then $sRet &= " ..."
    Return $sRet
EndFunc   ;==>_StringTruncate

Edit: Edited the code so it automatically uses @FILE for commandline
 
Edit Edit: Fixed a bug stopping includes from being processed.

Edit Edit Edit: Fixed a bug with it not showing include folder structure.
 
Scripts using compiling with:

#AutoIt3Wrapper_Run_Before=ShowOriginalLine.exe %in%
#AutoIt3Wrapper_Run_After=ShowOriginalLine.exe %in%

 
Should see a seamless functional error message, that displays the name of the current file and line number for that file.

Edited by nullschritt
Posted (edited)

@nullschritt I'm not getting compile this version you corrected.

Edited by Belini
Posted

@ nullschritt I'm not consiguindo compile this version you corrected.

 

More power to you. If you arn't intelligent enough to look at code and find if it's malicious or not, then it's probably a good idea!

Posted

The code is not malicious just can not compile.

 

I didn't catch your meaning. Make sure there is no problems in the code. If you just copy+paste it there is a formatting error at the top.

Click "pop-up" and copy it from there, then try!

Posted (edited)

running # AutoIt3Wrapper_AU3Check_Parameters =-d-w 1-w 2-w 3-w 4-w 5-w 6-w-7 I get 1 error (s) and 3 warning (s)
 

>Running AU3Check (3.3.9.4)  params:-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7  from:C:\Arquivos de programas\Autoit3
"C:\Documents and Settings\BELINI\Desktop\Test.au3"(83,91) : warning: $module possibly not declared/created yet
        $module = InputBox("Module Name", "Module Name (Leave Blank For Main Script)", "")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Documents and Settings\BELINI\Desktop\Test.au3"(180,88) : error: _ArrayToString() called with expression on Const ByRef-param(s).
    $filename = StringSplit(_ArrayToString(StringRegExp($sScriptPath, "(.*?)\.", 1), '')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Arquivos de programas\Autoit3\Include\Array.au3"(1264,81) : REF: definition of _ArrayToString().
Func _ArrayToString(Const ByRef $avArray, $sDelim = "|", $iStart = 0, $iEnd = 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Documents and Settings\BELINI\Desktop\Test.au3"(180,95) : warning: $filename possibly not declared/created yet
    $filename = StringSplit(_ArrayToString(StringRegExp($sScriptPath, "(.*?)\.", 1), ''), "\")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Documents and Settings\BELINI\Desktop\Test.au3"(184,101) : warning: $sPrgName: declared, but not used in func.
    Local $fMainFile = True, $hFileOpen, $hFileWrite, $iError = 0, $sModule = "•"&$module, $sPrgName,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\BELINI\Desktop\Test.au3 - 1 error(s), 3 warning(s)
!>10:22:02 AU3Check ended. Press F4 to jump to next error.rc:2
>Exit code: 0    Time: 1.835

without running AutoIt3Wrapper_AU3Check_Parameters = #-d-w 1-w 2-w 3-w 4-w 5-w I get 1 error

"C:\Arquivos de programas\Autoit3\Include\Array.au3"(1264,81) : REF: definition of _ArrayToString().
Func _ArrayToString(Const ByRef $avArray, $sDelim = "|", $iStart = 0, $iEnd = 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\BELINI\Desktop\Test.au3 - 1 error(s), 0 warning(s)
Edited by Belini
Posted (edited)

Where do I put these lines?

$regex = StringRegExp($sScriptPath, "(.*?)\.", 1)
$filename = StringSplit(_ArrayToString($regex, ''), "\")
Edited by Belini
Posted

 

Where do I put these lines?

$regex = StringRegExp($sScriptPath, "(.*?)\.", 1)
$filename = StringSplit(_ArrayToString($regex, ''), "\")

 

Replace the link erroring with these lines..... or update autoit.

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...