Jump to content
Sign in to follow this  
Jdop

Array error in compiled version but NEVER when run from editor

Recommended Posts

Jdop

Getting that cryptic array pointer error with a -1 line id (apparently from a library call ) in COMPILED but I never get the error when I run the same code from the editor. Seems odd, and since its fairly long and complex code, hard to debug.

Would be nice if the libraries actually passed the reason for crashing.

How to deal with this?

Share this post


Link to post
Share on other sites
JohnOne

I cannot help you, but others who may be able to will probably be able to do so easier if you give a full error you are getting, and version of autoit, and scite.

using latest versions of both, I always get an error with a line number from compiled script.


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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
trancexx

Update your AutoIt first, then ask.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
PsaltyDS

The message is not cryptic, you made an invalid array reference. Review the array references in your script. Put in a few _FileWriteLog(), TrayTip(), or ToolTip() debug statements in your script to see how far it got and what it was doing at the time.

If the script is too "long and complex" for you, then it's time to climb a little higher on the learning curve.

Don't give up, you can figure it out.

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
kaotkbliss

If I know approximately where my script went wrong, I like to add msgbox for each time a variable is called or changed in that part of the script. That helps me find where the problem is :mellow:


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites
Jdop

I updated to the latest version of Autoit. Lets see if that cures the problem.

Whats odd is , is never crashes when run in 'edit mode' only the compiled version. In theory that should not happen. The program loads live data from the internet so its constantly changing and therefore hard to debug if there's a random error.

Share this post


Link to post
Share on other sites
martin

I updated to the latest version of Autoit. Lets see if that cures the problem.

Whats odd is , is never crashes when run in 'edit mode' only the compiled version. In theory that should not happen. The program loads live data from the internet so its constantly changing and therefore hard to debug if there's a random error.

You can possibly find the line number if you compile the script as converted by the code below.

NB This was only written for 1D arrays and so would need changing for more dimensions, but the basic idea is there.

#include <file.au3>

$PresentScriptname = "tproblemscript.au3";<------------put your file name here
$DebugScriptName = "debugfile.au3";<--------put the name of the copy here
$ArrayName = "$brray";<-----------put your array variable name here


$Newf = FileOpen($DebugScriptName, 2)
Global $text
_FileReadToArray($PresentScriptname, $text)
For $n = 1 To $text[0]
    If StringLeft(StringStripWS($text[$n], 1), 3) <> "Dim" Then
        
        $sl = StringRegExp($text[$n], "\" & $ArrayName & "\[.*?\]",3)
        if isarray($sl) then 
            for $k = 0 to ubound($sl) - 1
                FileWriteLine($Newf,StringRegExpReplace($sl[$k], ".*(\" & $ArrayName & "\[)(.*)?(\])", "CheckArray(\" & $ArrayName & ",\2," & $n & ")",1) )
            Next
        EndIf
        
    EndIf
    FileWriteLine($Newf,$text[$n])
    
Next
FileWriteLine($Newf, @CRLF & "Func CheckArray($aA,$iS, $iLn)")
FileWriteLine($Newf, @TAB & "if UBound($aA) < $iS + 1 then ")
FileWriteLine($Newf, @TAB & @TAB & 'MsgBox(262144,"ERROR on line" & $iLN, "Array has " & UBound($aA) & " elements," & @CRLF & "but " & $iS & " called for")')
FileWriteLine($Newf, @TAB & @TAB & 'exit')
FileWriteLine($Newf, @TAB & 'Else')
FileWriteLine($Newf, @TAB & @TAB & 'Return $aA[$iS]')
FileWriteLine($Newf, @TAB & 'EndIf')
FileWriteLine($Newf, 'EndFunc')

FileClose($Newf)

Note that the line number reported with the error is the line number in the original script not the debug script.

I have only tried it on a simple example so it probably needs some improvements.

EDIT: Changed to allow for the Array variable appearing more than once on a line.

But really you should write your script so that the error doesn't occur, but since you haven't shown any code we can only guess.

Edited by martin

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.

Share this post


Link to post
Share on other sites
Jdop

I'm getting the same error, only now it reports Error at line 13333. Obviously this is not much more helpful than line -1

Share this post


Link to post
Share on other sites
Melba23

Jdop,

Obviously this is not much more helpful than line -1

Why not? It tells you exactly where the error is, which is why trancexx told you to upgrade your Autoit version. :(

Now your problem is to work out which line of code 13333 actually is - as the compiler strips out all comments and blanks. Did you run the code through Obfuscator when compiling? If you had, you would find a file "filename_Obfuscated.au3" in the same folder as your script which is what the compiler actually used to produce the final script. If you had used the /StripOnly parameter with Obfuscator you would have automatically stripped all the comment and blank lines, so the line given in the error message would refer directly to that line in the Obfuscated file. And then you would know where the problem lies! :lol:

If want to try this, you need the full SciTE4AutoIt3 package, which you can download from here. You get lots of other goodies as well, so it is well worth it. :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
martin

Jdop,

Why not? It tells you exactly where the error is, which is why trancexx told you to upgrade your Autoit version. :(

Now your problem is to work out which line of code 13333 actually is - as the compiler strips out all comments and blanks. Did you run the code through Obfuscator when compiling? If you had, you would find a file "filename_Obfuscated.au3" in the same folder as your script which is what the compiler actually used to produce the final script. If you had used the /StripOnly parameter with Obfuscator you would have automatically stripped all the comment and blank lines, so the line given in the error message would refer directly to that line in the Obfuscated file. And then you would know where the problem lies! :lol:

If want to try this, you need the full SciTE4AutoIt3 package, which you can download from here. You get lots of other goodies as well, so it is well worth it. :mellow:

M23

The code I provided gives the line in the original script. So line 1333 is just that. It also tells you the index and the array UBound. You can eassily extend the code I gave to tell you more, for example the values of other variables.

EDIT: I suppose I have to assume the OP has not actually tried my code.

Edited by martin

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.

Share this post


Link to post
Share on other sites
Jdop

I'm getting pointers to line numbers that are not array related, even though the error message says "array error". Is there some 'wiggle room' in the line number thats reported in the obfuscated code.

Share this post


Link to post
Share on other sites
trancexx

Are you using /striponly only?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Jdop

Yes, I am. I've gotten some line pointers that make sense, and some that don't. I'm working on it.

Share this post


Link to post
Share on other sites
MariusN

I usually get that error when i forget to declare my variable...

Share this post


Link to post
Share on other sites
Jdop

I usually get that error when i forget to declare my variable...

Are you saying you get a bogus error or line number when you use an undeclared var?

The var on the error I am getting was undeclared, so I added it to the DIM's. Let's see if that cures it.

Wondering if that 'declaration' issue would cause a difference in compiled vs. editor operation, as I never seem to get that error running off Scite.

Edited by Jdop

Share this post


Link to post
Share on other sites
MvGulik
whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.