Thlitmi Posted December 5, 2010 Posted December 5, 2010 (edited) #include <Array.au3> $q=StringSplit("46,13,54,94,56,78,15,48,26,54,44,84,73,26,64",",") $p=1 While $p<_ArrayMax($q) If $q[$p]=14 Then _ArrayDelete($q, $p) EndIf $p=$p+1 WEnd _ArrayDisplay($q)(5) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceededI think there is no error in it.And I do not know what is array subscript... Is it array index number ? Edited December 5, 2010 by Thlitmi
Developers Jos Posted December 5, 2010 Developers Posted December 5, 2010 What should this test for in your mind? While $p < _ArrayMax($q) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Paulie Posted December 5, 2010 Posted December 5, 2010 (edited) #include <Array.au3> $q=StringSplit("46,13,54,94,56,78,15,48,26,54,44,84,73,26,64",",") $p=1 While $p<_ArrayMax($q) If $q[$p]=14 Then _ArrayDelete($q, $p) EndIf $p=$p+1 WEnd _ArrayDisplay($q) (5) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded You problem is that _ArrayMax() returns the highest value held in the array, which in your case is 94. You then try look at the 95th element in the array with $q[$p], which throws an error cause you have exceeded the range of the array. Replace _ArrayMax() with UBound() and you should be fine. #include <Array.au3> $q=StringSplit("46,13,54,94,56,78,15,48,26,54,44,84,73,26,64",",") $p=1 While $p < UBound($q) If $q[$p]=14 Then _ArrayDelete($q, $p) EndIf $p=$p+1 WEnd _ArrayDisplay($q) Edited December 5, 2010 by Paulie
Thlitmi Posted December 5, 2010 Author Posted December 5, 2010 Well,I dont fully understand your english, but you are asking what do I want to do with that code ? _ArrayMax($q) is a number array values, there is 15 values so it will loop 15x times. is there a better way to tell the loop number of cycles the same as array value number count is ? Or is there a beter loop than while ? :-D maybe yes, I will try, but you can help me anyway : ) ) ) )
Zedna Posted December 5, 2010 Posted December 5, 2010 array index is counted from 0 to Ubound() - 1 not from 1 to UBound() Resources UDF ResourcesEx UDF AutoIt Forum Search
Thlitmi Posted December 5, 2010 Author Posted December 5, 2010 > Paulie Oh my goodnes !!!! So _ArrayMax has no place in my script !!!!!!!!!!!!! I was using it to count array values I will change it and try....
Thlitmi Posted December 5, 2010 Author Posted December 5, 2010 > Zenda Now I know that _ArrayMax is a nonsence to use in this script. It was a mistake, that I used it, because I overlooked its description. ""array index is counted from 0 to Ubound() - 1 not from 1 to UBound()"" I know, but it has no meaning in here, because I get the correct number of loops and $p is correct number as needed. And I do not need to work with $p[0] exept I could use . . . While $p < $p[0] (Why didn't I use it in the first place..... ? ) But this topic is [sOLVED]
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