Jump to content

Compiled scripts and error line number


Recommended Posts

Hi everyone.

Im using autoit 3.3.0.0

I would like to know if line numbers can be displayed when an error occurs on a compiled script..

Im running the script at the end of this post, but the line number is always -1 . Am I doing somethign wrong?

thanks in advance

Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

;----------------------------------------------------------------------------------------------------------

; Com Error Handler

;----------------------------------------------------------------------------------------------------------

Func MyErrFunc()

Local $HexNumber

Local $strMsg

$HexNumber = Hex($oMyError.Number, 8)

$strMsg = "Error Number: " & $HexNumber & @CRLF

$strMsg &= "WinDescription: " & $oMyError.WinDescription & @CRLF

$strMsg &= "Script Line: " & $oMyError.ScriptLine & @CRLF

MsgBox(0, "ERROR", $strMsg)

SetError(1)

Endfunc

$test = 0

MsgBox(0,"test","test",$test[0])

Link to comment
Share on other sites

Hi everyone.

Im using autoit 3.3.0.0

I would like to know if line numbers can be displayed when an error occurs on a compiled script..

Im running the script at the end of this post, but the line number is always -1 . Am I doing somethign wrong?

thanks in advance

Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

;----------------------------------------------------------------------------------------------------------

; Com Error Handler

;----------------------------------------------------------------------------------------------------------

Func MyErrFunc()

Local $HexNumber

Local $strMsg

$HexNumber = Hex($oMyError.Number, 8)

$strMsg = "Error Number: " & $HexNumber & @CRLF

$strMsg &= "WinDescription: " & $oMyError.WinDescription & @CRLF

$strMsg &= "Script Line: " & $oMyError.ScriptLine & @CRLF

MsgBox(0, "ERROR", $strMsg)

SetError(1)

Endfunc

$test = 0

MsgBox(0,"test","test",$test[0])

you have a MsgBox to display $test[0], but $test[0] was never set to my knowledge?
Link to comment
Share on other sites

you have a MsgBox to display $test[0], but $test[0] was never set to my knowledge?

Yes, that was on purpose so the scripts throws an error... but that is not my problem, the problem is that when I run that script compiled I dont get the line number where the error is generated
Link to comment
Share on other sites

Yes, that was on purpose so the scripts throws an error... but that is not my problem, the problem is that when I run that script compiled I dont get the line number where the error is generated

So add a func to help you debug.

Use "half splitting" with this line _dbgTIP(6)

Global $line
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

_dbgTIP(6)
MsgBox(0, "test", "test", $test[0])

Func MyErrFunc()
    ;nothing
EndFunc   ;==>MyErrFunc

Func _dbgTIP($line)
    TrayTip("", $line, 100)
    Sleep(10000)
EndFunc   ;==>_dbgTIP

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

...the problem is that when I run that script compiled I dont get the line number where the error is generated

No, the problem is, you shouldn't be running a compiled version of a script until you've thoroughly tested it by running it non-compiled.
Link to comment
Share on other sites

No, the problem is, you shouldn't be running a compiled version of a script until you've thoroughly tested it by running it non-compiled.

$var = "C:\temp\devicetable.log"
FileInstall("C:\devicetable.log", $var)
Are there other AutoIt functions that only "work" in non-compiled scripts when used with the improper syntax?

@OP,

Are you using FileInstall somewhere in your code?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

$var = "C:\temp\devicetable.log"
FileInstall("C:\devicetable.log", $var)
Are there other AutoIt functions that only "work" in non-compiled scripts when used with the improper syntax?
Is there something wrong with the syntax in your example?
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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...