Phenom Posted August 16, 2010 Share Posted August 16, 2010 (edited) I have a compiled AutoIt program which works sometimes, and sometimes doesn't. When it crashes it says, Line 7749 Error : Subscript used with non-array variable. What are the possible causes for this? It used to work, so I don't think the problem is in the code. I checked the amount of free memory I have and it should be sufficient. Edited August 16, 2010 by Phenom Link to comment Share on other sites More sharing options...
water Posted August 16, 2010 Share Posted August 16, 2010 I have a compiled AutoIt program which works sometimes, and sometimes doesn't. When it crashes it says, Line 7749 Error : Subscript used with non-array variable. What are the possible causes for this? It used to work, so I don't think the problem is in the code. I checked the amount of free memory I have and it should be sufficient.The problem is that you try to access a non-array variable like an array. I have experienced this kind of problem when you call a function that returns an array on success but an empty string on error (and sets @error).In this case either check @error after the function call (best choice) or use "IsArray" to check the return value. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MvGulik Posted August 16, 2010 Share Posted August 16, 2010 (edited) ... check @error after the function call (best choice) or use "IsArray" to check the return value.Checking for @error value is indirect. Using IsArray() is direct.Better to use direct checkups. Especially when trying to track down the source of a active problem.---Phenom,Start dropping "If Not IsArray($YourArray) Then Exit 991/992/etc" lines after code line that assign data to that array variable. (or if your running your code in script mode, use "... Exit @ScriptLineNumber")Look for "$YourArray = ..." and "function(..., Byref $YourArray, ...)" cases. Edited August 16, 2010 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 ... Link to comment Share on other sites More sharing options...
water Posted August 16, 2010 Share Posted August 16, 2010 Checking for @error value is indirect. Using IsArray() is direct.Better to use direct checkups. Especially when trying to track down the source of a problem.I assume a correctly written function that sets @error if an error occurred. So I think first checking if an error occurred and if @error=0 then process the returned data is good programming practice.But I could be wrong My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MvGulik Posted August 16, 2010 Share Posted August 16, 2010 I assume a correctly written function that sets @error if an error occurred. So I think first checking if an error occurred and if @error=0 then process the returned data is good programming practice.But I could be wrong "good programming practice": I agree."assume a correctly written function" on someone else his (unkown) used code. ... Unsafe at best. "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 ... Link to comment Share on other sites More sharing options...
water Posted August 16, 2010 Share Posted August 16, 2010 "assume a correctly written function" on someone else his (unkown) used code. ... Unsafe at best. Sometimes I'm a bit too optimistic As we haven't seen the OPs code he can either enhance his own functions or use belt and suspenders to be sure he is on the safe side My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now