e2e4au Posted May 13, 2005 Share Posted May 13, 2005 This is the code and error - I am reading in sections from INI file. The Code --------------------------------------- $i=UBound($avCRanking) Do If _ArrayMax($avCRanking,1) = $avCRanking[$i] Then $1=StringFormat("%s%s%s%s",$i,"(",_ArrayMax($avCRanking,1),")") _ArrayAdd($Sorted,$1) _ArrayDisplay($Sorted,"Sorted") _ArrayDelete($avCRanking,$i) $i=$i-1 Else $i=$i-1 EndIf Until _ArrayMax($avCRanking,1) = 0 --------------------------------------------------------- ERROR: -------------------------------- TestScript.au3 (20) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If _ArrayMax($avCRanking,1) = $avCRanking[$i] Then If _ArrayMax($avCRanking,1) = ^ ERROR --------------------------------- Thanks in advance! Link to comment Share on other sites More sharing options...
GaryFrost Posted May 13, 2005 Share Posted May 13, 2005 Once you delete the last element it is no longer an arrayfrom help file _ArrayDeleteIf the array passed in has only 1 element, this function returns an empty string.Suggest you have if (IsArray($avCRanking)) then statement in your code to check if it is still an array. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 13, 2005 Developers Share Posted May 13, 2005 try : $i=UBound($avCRanking) -1 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. Link to comment Share on other sites More sharing options...
e2e4au Posted May 13, 2005 Author Share Posted May 13, 2005 Once you delete the last element it is no longer an arrayfrom help file _ArrayDeleteSuggest you have if (IsArray($avCRanking)) then statement in your code to check if it is still an array.<{POST_SNAPBACK}>Thanks for the help!I have reread the help file and the statement reads.Deletes the specified element from the given array, returning the adjusted array. The key here is [B]"returning the adjusted array"[/B] I have included a Test.ini Below and the Test script code, Test.ini ---------------------------------------- [TestSection] P1 = 11 P2 = 34 P3 = 22 P4 = 14 P5 = 7 P6 = 10 P7 = 15 P8 = 9 P9 = 16 P10 =12 P11 = 3 P12 = 17 P13 = 211 P14 = 334 P15 = 119 P16 = 418 P17 = 620 P18 = 111 P19 = 5648 P20 = 2122;Testing Script#include <Array.au3>Dim $i, $1, $var, $avCRanking[1],$Sorted[1]$var = IniReadSection("Test.ini", "TestSection")For $i=1 To $Var[0][0] _ArrayAdd($avCRanking, $var[$i][1])Next_ArrayDisplay($avCRanking," ")$i=UBound($avCRanking)-1Do If _ArrayMax($avCRanking,1) = $avCRanking[$i] Then $1=StringFormat("%s%s%s%s",$i,"(",_ArrayMax($avCRanking,1),")") _ArrayAdd($Sorted,$1) _ArrayDisplay($Sorted,"Sorted") _ArrayDelete($avCRanking,$i) $i=$i-1 Else $i=$i-1 EndIf Until _ArrayMax($avCRanking,1) = 0 Link to comment Share on other sites More sharing options...
e2e4au Posted May 13, 2005 Author Share Posted May 13, 2005 I have figured out why the error was occuring. $i was not getting reset in the inner If statement. was > $i=$i+1 needed > $i=0 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