Jump to content

AutoIt Error PopUp in Executable, How to find the line in Source Code?


Recommended Posts

This is only a example PopUp window, the error I'm getting is: variable must be of type Object

AutoIt Error

Line 12467 "(File: D:\AutoIt_Teste\GetFileLineError.exe")

Error: Arrary variable has incorrect number of subscripts or subscript

dimension rage exceeded.

How can a find the Source Code line that caused this error?

I tried to make a program that count the lines of the Include files, but it didn't work.

I'm attaching the program code, I used to find the line error on the file

Executable Error in Line12452

In the test program the error is in line 110 but my program report Line 834

the program and the test program are the same.

the line to make the error occur is:

If @Compiled And $as[uBound($as)] = "" Then $i=$i ; PopUp ERROR wen compiled

; IS NOT WORKING if includes present
;===============================================================================
;
; Program Name:  GetFileLineError
; Description:  Find the line of File given the error line reported by the compiled program
;    Ueses a Recursive call Sistem
;
; Parameter(s):  $Path Program full path of Sorce program Ex.   $path="C:\users\jony\autoit test\teste.au3"
;                  $Errorline              Ex.   $Errorline = 6551 ; Executable reported error Line
;    $Debug Debug level,   Defulat 0 No trce
;     1- Start and End File Lines,
;     2- File #include line  Format:>(ident space)(FileName):(File Line)  (Line text)
;     3- #include-once List
;
; Requirement(s):   Source code used to create the executable
;    $includePath Path of Include files with "\" Ex. $includePath="C:\Program Files (x86)\AutoIt3\Include\"
;
; Return Value(s): ConsoleWrite  with de Program ou Mudule name and da file line of the error And MsgBox
;
; Author(s):  Elias Assad Neto
; Date Created:  June 6 2012
;
;===============================================================================
; Parameters Input
$ProgramPath = "GetFileLineError.au3"
$Errorline = 12452; Executable error Line
$Debug = 2  ; Debug Level

; Includ Path ended with "\"
$includePath="C:\Program Files (x86)\AutoIt3\Include\"
If Not FileExists($includePath) Then $includePath="C:\Program Files\AutoIt3\Include\"
If Not FileExists($includePath) Then
MsgBox(0x10,"GetFileLineError"," Include File Directory Not Found")
Exit
EndIf

; Var initialization ========================================
$i = StringInStr($ProgramPath,"\",0,-1) ; Last "\" position
$dir = StringLeft($ProgramPath,$i) ; Path Dir with "\"
$file = StringMid($ProgramPath,$i+1) ; Program name
$includeOnce = "" ; Include-Once File List
$line = 0
$RecursionLevel = 0 ; Recursion Level used to ident debug lines
; Program Start =============================================
#include <INet.au3> ; Para enviar e-Mail em caso de *ERRO
#include <IE.au3>
#include <File.au3>
#include <Array.au3>
#include <GuiStatusBar.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ProgressConstants.au3> ;3.3.0.0
#include <WindowsConstants.au3> ;3.3.0.0
#include <StaticConstants.au3>
#include <Timers.au3>
$S = ProcessFile($file,$Debug)
ConsoleWrite(@CRLF & @CRLF & $S & @CRLF)
If $S <> "" Then
MsgBox(0x40,"GetFileLineError",$S)
Else
MsgBox(0x40,"GetFileLineError","Executable Line " & $Errorline & " Not Found in: " & $file)
EndIf

; Program End ===============================================
; Function Decalration ======================================
Func ProcessFile($FileName, $Trace=0) ; Recursive fuction to find Line, Debug Level 0,1,2,3
$ph = $dir;
$s = FileRead($ph & $FileName) ; Search File in the source directory
If $s = ""  Then
  $ph = $includePath
  $s = FileRead($ph & $FileName) ; Search File in the Include directory
EndIf
$phf = $ph & $FileName
If $s = "" Then Return "ERROR File " & $FileName & " NOT Found Search for Error line Aborted"
$t = ""
For $i=1 To $RecursionLevel  ; Ident formating
  $t &= @TAB
Next
If StringInStr(StringLeft($s,16),"#include-once")=1 Then ; File #include-once detectaed
  If StringInStr($includeOnce,$FileName) Then Return ; Return file already processed
  $includeOnce &= $FileName & ";"; Adds the name of the File in the includeOnce list
  If $Trace >=3 Then ConsoleWrite($t & '$includeOnce="' & $includeOnce & '"' & @CRLF) ; Debug level 3
EndIf
If $RecursionLevel = 0 Then
  If $Trace Then ConsoleWrite("+" & $t & "Programa Start( " & $FileName & " ) line " & $line+1 & @CRLF) ; Debug level >=1
Else
  If $Trace Then ConsoleWrite("+" & $t & "Include  Start( " & $FileName & " ) line " & $line+1 & @CRLF) ; Debug level >=1
EndIf
$RecursionLevel +=1
$s1 = ""
Do ; ExitLoop Block
  $as = StringSplit($s,@CRLF,1) ; String to Array
  If @Compiled And $as[UBound($as)] = "" Then $i=$i ; PopUp ERROR wen compiled
  For $i=1 to UBound($as)-1 ; $i File Line
   $line+=1 ; Incrementa a linha Global
   If $line = $Errorline Then ; Achou a Linha terminou
    $s1 = "ERROR Line Found in " & $phf & " at File Line: " & $i ; Nome do Modulo mais linha local
    Return $s1 ; Retorna com o dado e termina a recursividade
   EndIf
   If StringInStr(StringStripWS($as[$i],3),'#include ')=1 then
    $as1 = StringRegExp($as[$i],"(?i)\#include (<(.*)>|""(.*?)""|''(.*?)'')",3) ; pega o nome do modulo <xxx>, "xxx" ou 'xxx'
    If UBound($as1)>1 Then ; Ok
     $s1 = $as1[UBound($as1)-1] ; takes the last item that is the file name
     If $Trace >=2 And StringInStr($includeOnce,$s1)=0 Then ConsoleWrite(">" & $t & $FileName & ":" & $i & "  " & $as[$i] & @CRLF) ; Debug level >=2
     $s1 = ProcessFile($s1,$Trace) ; Here comes recursion
     If $s1 <> "" Then ExitLoop ; Get out of the recursion cascading exiting all levels
    EndIf
   EndIf
  Next
Until 1
$RecursionLevel -=1
If $s1 = "" Then
  If $RecursionLevel = 0 Then
   If $Trace Then ConsoleWrite("-" & $t & "Programa  End( " & $FileName & " ) line " & $line & " Program File Lines: " & UBound($as)-1 & @CRLF) ; Debug level >=1
  Else
   If $Trace Then ConsoleWrite("-" & $t & "Include   End( " & $FileName & " ) line " & $line & " Include File Lines: " & UBound($as)-1 & @CRLF) ; Debug level >=1
  EndIf
EndIf
Return $s1 ; Return "" if Includ end, or is $s1 <> "" is da result exiting all recursion levels
EndFunc

Tks.

GetFileLineError.au3

Edited by Elias
Link to comment
Share on other sites

  • Moderators

Elias,

The line numbers are different because of all the #include files that are added at the top of your script. :)

The way to get round this is to compile the script using Obfuscator and the /Strip Only parameter - you need the full SciTE4AutoIt3 package to do this which you can download from here. This provides you with a ScriptName_Obfuscated.au3 file where the line numbers match those in the executable. ;)

But if you are sure that the error occurs in that line, you can add some errorchecking like this:

If (Not IsArray($as)) Or (@Compiled And $as[UBound($as)] = "") Then $i=$i

Now you will error if the array does not exist and you will not try to read a non-existent element. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I have not managed to get the obfuscator approach to work for me because half of my functions are invoked as "CALL" commands, i.e. they look like dead code and I think Obfuscator removes them.

This might be tweakable with a setting, but I've always managed to find these occurrences by running the script under ScITE. If your script requires command line parameters, there is a ScITE menu to provide this. If your script will run with F5, this is by far the most convenient way to find these errors.

Link to comment
Share on other sites

  • Moderators

clicked,

Just out of interest, why do you use Call so often? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I have a networked set of participants, where one instance reads a command file that describes what command to run where, it marshals the command and sends it to the correct participant, which unpacks the command and CALLs it.

I had a lot of trouble early on with array bounds problems, and tried Obfuscator with no success. However, the script runs great under ScITE and it never fails to find the exact failure line.

Link to comment
Share on other sites

  • Moderators

clicked,

Thanks for that - I do the same thing from time to time but I wanted to make sure that you had a good reason for using Call as we see a lot of people using it unnecessarily. :)

I quite agree that trying to find the error by running SciTE is the best idea - but at times it just does not work. Have you tried the #Obfuscator_Ignore_Funcs directive to prevent Obfuscator from stripping those functions from your script? It might be a solution if ever you need it. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Elias,

The line numbers are different because of all the #include files that are added at the top of your script. :)

The way to get round this is to compile the script using Obfuscator and the /Strip Only parameter - you need the full SciTE4AutoIt3 package to do this which you can download from here. This provides you with a ScriptName_Obfuscated.au3 file where the line numbers match those in the executable. ;)

But if you are sure that the error occurs in that line, you can add some errorchecking like this:

If (Not IsArray($as)) Or (@Compiled And $as[UBound($as)] = "") Then $i=$i

Now you will error if the array does not exist and you will not try to read a non-existent element. :)

M23

Thanks

Elias

Link to comment
Share on other sites

Elias,

The line numbers are different because of all the #include files that are added at the top of your script. :)

The way to get round this is to compile the script using Obfuscator and the /Strip Only parameter - you need the full SciTE4AutoIt3 package to do this which you can download from here. This provides you with a ScriptName_Obfuscated.au3 file where the line numbers match those in the executable. ;)

But if you are sure that the error occurs in that line, you can add some errorchecking like this:

If (Not IsArray($as)) Or (@Compiled And $as[UBound($as)] = "") Then $i=$i

Now you will error if the array does not exist and you will not try to read a non-existent element. :)

M23

I've got a lot of errors, I use a lot of CALL do to Removable/Addable #includes

my Call works like a Swich

-### StripOnly Error: Found Call() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by the Call() statement.

>### current Func: ProcessaMatriz

D:PROGRAMMMSC_ConsultaSiscargaConsultaSisCargaConsultaSisCarga.au3(2758,1) Warning for line:If $IDENTBusy Then Call($IDENT & "_Timer")

-#############################################################################################

-#### Obfuscator Found 32 Error(s)!!!! This means your script could have problems running properly. ####

-#############################################################################################

- Iteration 1 Strip Functions result: Output 8418 lines and stripped 15749 lines

- Iteration 2 Strip Variables result: Output 0 lines and stripped 0 lines

Is there another way to get a continuous code .au3 ?

tks

Link to comment
Share on other sites

I have not managed to get the obfuscator approach to work for me because half of my functions are invoked as "CALL" commands, i.e. they look like dead code and I think Obfuscator removes them.

This might be tweakable with a setting, but I've always managed to find these occurrences by running the script under ScITE. If your script requires command line parameters, there is a ScITE menu to provide this. If your script will run with F5, this is by far the most convenient way to find these errors.

Thanks

is what I'm doing now the problem is that the error is quit difficult to happen, is a system that automatize several secure pages for input an output data whit different uses of certificates in IE and communicates with a SQL server.

Link to comment
Share on other sites

  • Moderators

Elias,

Did you see my comment to clicked above about using #Obfuscator_Ignore_Funcs? I admit I have not used it myself, but it should work if I understand the directive correctly. :)

Other than that, did you try running the script from within SciTE on the same data to see if you can reproduce the error? That way you would get the correct line returned. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Elias,

Did you see my comment to clicked above about using #Obfuscator_Ignore_Funcs? I admit I have not used it myself, but it should work if I understand the directive correctly. :)

Other than that, did you try running the script from within SciTE on the same data to see if you can reproduce the error? That way you would get the correct line returned. ;)

M23

Tried, didn´t work

Places as #Obfuscator_Ignore_Funcs in the first colum

Link to comment
Share on other sites

  • Moderators

Elias,

I have now tested the directive and it worked perfectly for me. You need these lines at the top of the script:

#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#Obfuscator_Ignore_Funcs=_Func_1,_Func_2,_Func_3,_Func_4

Just replace the _Func_# names with the function names you do not want Obfuscator to strip. :)

And have you tried running from within SciTE? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Elias,

I have now tested the directive and it worked perfectly for me. You need these lines at the top of the script:

#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#Obfuscator_Ignore_Funcs=_Func_1,_Func_2,_Func_3,_Func_4

Just replace the _Func_# names with the function names you do not want Obfuscator to strip. :)

And have you tried running from within SciTE? ;)

M23

Yes I'm using SciTE now to find the problem, I had to install the System at the client ans stay watching remotely.
Link to comment
Share on other sites

  • 3 weeks later...

Yes I'm using SciTE now to find the problem, I had to install the System at the client ans stay watching remotely.

Hello, I run with SciTE, but the memory of the system overflew before , the problem occurred, is there a way to make the memory Buffer STDOUT rotating for de debug window?

tks

Link to comment
Share on other sites

  • 2 weeks later...

Error Resolved, AutoIt Error: variable must be of type Object

This error was occurring in the AutoItScript 3.3.6.1 #include <IE.au3> in:

Func __IEInternalErrorHandler()
$IEComErrorScriptline = $oIEErrorHandler.scriptline ; <<< Error here
:
:
If $_IEErrorNotify Or $__IEAU3Debug Then ConsoleWrite($IEComErrorOutput & @CRLF)
SetError($_IEStatus_ComError)
Return
EndFunc ;==>__IEInternalErrorHandle

; Solution

Func __IEInternalErrorHandler()
If isObject($oIEErrorHandler) Then
$IEComErrorScriptline = $oIEErrorHandler.scriptline
;:
;:
Else
$IEComErrorOutput = "$IEComErrorOutput is Not Object"
EndIf
If $_IEErrorNotify Or $__IEAU3Debug Then ConsoleWrite($IEComErrorOutput & @CRLF)
SetError($_IEStatus_ComError)
Return
EndFunc ;==>__IEInternalErrorHandle
Link to comment
Share on other sites

Error Solved, AutoIt Error: variable must be of type Object

This error was occurring in the AutoItScript 3.3.6.1 #include <IE.au3>

Func __IEInternalErrorHandler()
     $IEComErrorScriptline = $oIEErrorHandler.scriptline ; <<< Error here
     ;
     ;
     If $_IEErrorNotify Or $__IEAU3Debug Then ConsoleWrite($IEComErrorOutput & @CRLF)
     SetError($_IEStatus_ComError)
     Return
EndFunc ;==>__IEInternalErrorHandle

; Solution

Func __IEInternalErrorHandler()
     If isObject($oIEErrorHandler) Then ; Solution is to test if is rely an Object
         $IEComErrorScriptline = $oIEErrorHandler.scriptline
         ;
         ;
     Else
         $IEComErrorOutput = "$IEComErrorOutput is Not Object"
     EndIf
     If $_IEErrorNotify Or $__IEAU3Debug Then ConsoleWrite($IEComErrorOutput & @CRLF)
     SetError($_IEStatus_ComError)
     Return
EndFunc ;==>__IEInternalErrorHandle
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...