RvBSvnhO Posted April 3, 2012 Share Posted April 3, 2012 (edited) Hey people, I move for a while with AutoIt. Just who is giving an error that I have never seen yet.The error is the following:(Ubound) - 1 contained in the for, is reading the array after then falls over with -1. And coming back with error "Subscript used with non-Array variable."Why ?Exemple :Local $arr1[3] = [ '1', '2', '3'] Local $arr2[3] = ['2', '3', '4'] Local $i For $i = 0 to UBound($arr1) -1 if _arraySearch($arr2, $arr1[$i]) = -1 then If _ArraySearch($arr2, $arr1^ ERROR EndIf NextRvB #SvnhO¹ Edited April 3, 2012 by RvBSvnhO Link to comment Share on other sites More sharing options...
kaotkbliss Posted April 3, 2012 Share Posted April 3, 2012 (edited) The array starts at 0, you are looking for -1 which does not existarray 0 is usually the number of items in the array, so when you Ubound(array)-1, you are telling it not to use array 0I glanced over the first 2 lines and didn't register them.1 thing I noticed is you use _arraySearchis should be _ArraySearchyou also need to include the array udf (not sure if you are in your main script or not)other than that, it's working correctly for me.#Include <Array.au3> Local $arr1[3] = [ '1', '2', '3'] Local $arr2[3] = ['2', '3', '4'] Local $i For $i = 0 to UBound($arr1)-1 if _ArraySearch($arr2, $arr1[$i]) = -1 then MsgBox(0,"",@error) Next*edit*#Include <Array.au3> Local $arr1[3] = [ '1', '2', '3'] Local $arr2[3] = ['2', '3', '4'] Local $i Local $search For $i = 0 to UBound($arr1)-1 $search = _ArraySearch($arr2, $arr1[$i]) if $search = -1 then MsgBox(0,"error",@error) If $search <> -1 Then MsgBox(0,"found",$search) Next*edit*in the 2nd example, you can see that it does not find "1" in array2 (error "6")it finds "2" in array2 at position 0, and finds "3" in array2 at position 1then exits because there are no more values in array1 Edited April 3, 2012 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
BrewManNH Posted April 3, 2012 Share Posted April 3, 2012 I'm not getting any errors with that script. Although I'm assuming the second If/Then line was showing the error and also assuming you used #include <Array.au3> in the real script somewhere. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
RvBSvnhO Posted April 3, 2012 Author Share Posted April 3, 2012 Yes, that's right. Only for inside, it reads like Ubound as the size of array and then he falls to -1.Exemplo :For $i = 0 to Ubound($Array1)-1 ConsoleWrite(";"Ubound($Array1)-1) ; 2 After ; - 1 NextWhy ? Link to comment Share on other sites More sharing options...
RvBSvnhO Posted April 3, 2012 Author Share Posted April 3, 2012 BrewManNHYes, the #Include <Array.au3>, is already included. Link to comment Share on other sites More sharing options...
RvBSvnhO Posted April 3, 2012 Author Share Posted April 3, 2012 kaotkblissIs Erro = 6 , not Array.As I said earlier in the topic - "Subscript used with non-Array variable." Link to comment Share on other sites More sharing options...
BrewManNH Posted April 3, 2012 Share Posted April 3, 2012 What do you mean it falls to -1, when is this happening? Because it's not happening in your script. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
RvBSvnhO Posted April 3, 2012 Author Share Posted April 3, 2012 BrewManNHSorry, I got just one example. My script is in StringRegExp, picking up 22 arrays. Only the Ubound is listing to 21 and then goes to -1 giving error in $ i. Link to comment Share on other sites More sharing options...
GEOSoft Posted April 3, 2012 Share Posted April 3, 2012 the array search function returns -1 if the search string is not found otherwise returns the first array element where it is found. also kaotkbliss autoit is not case sensitive George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted April 3, 2012 Share Posted April 3, 2012 BrewManNHSorry, I got just one example. My script is in StringRegExp, picking up 22 arrays. Only the Ubound is listing to 21 and then goes to -1 giving error in $ i.use ubound -1 as the limit. not ubound and stringregexp returns a zero based array, not 1 based. that means you have to stop at ubound -1 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
RvBSvnhO Posted April 3, 2012 Author Share Posted April 3, 2012 (edited) GEOSoftYes, I Know.Except that the error is in the Ubound($Array1) -1 read as 21 and then reads as -1, you should remain at 21. (Inside for) Edited April 3, 2012 by RvBSvnhO Link to comment Share on other sites More sharing options...
BrewManNH Posted April 3, 2012 Share Posted April 3, 2012 You're going to need to post a script that demonstrates that, because I've never seen that before, unless you're deleting array elements inside your For loop. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
RvBSvnhO Posted April 3, 2012 Author Share Posted April 3, 2012 (edited) The variable was equal to the Ubound of the other inside it, why he was reading once, and the second accused was not to be an array in For Loop. Sorry, people. I can not believe I did not see iso, you can close the topic. Thank for much you all. RvB #SvnhO Edited April 3, 2012 by RvBSvnhO Link to comment Share on other sites More sharing options...
kaotkbliss Posted April 3, 2012 Share Posted April 3, 2012 also kaotkblissautoit is not case sensitiveI know, but I find it good practice and have a habit of making sure cases match (just in case) so I see it as an error 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
BrewManNH Posted April 3, 2012 Share Posted April 3, 2012 Run Tidy on the script, it will fix those types of "mistakes". If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 3, 2012 Moderators Share Posted April 3, 2012 BrewManNH, Took the words right out of my mouth! M23 P.S. Or to be absolutely correct - the keys right off my keyboard! 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RvBSvnhO Posted April 3, 2012 Author Share Posted April 3, 2012 BrewManNHThanks for the tip. ; )I've got here.Thank for much you all.8) 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