ds34 Posted December 5, 2008 Share Posted December 5, 2008 I am using for loops to check conditions in arrays, i.e CODEFor $i = 1 To UBound($CIT_list) - 1 If $CIT_list[$i]=$CIT_list[$i-1] Then _ArrayDelete($CIT_list,$i) Next This code occasionally crashes: : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If $TID_list[$i]=$TID_list[$i-1] Then _ArrayDelete($TID_list,$i) If ^ ERROR As it appears to me the stop value of the FOR loop is declared upon first run of the loop, i.e. it does not check each run, if the arraysize has changed, thus crashing when removing an entry and changing the arrays dimension? Am I right? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 5, 2008 Developers Share Posted December 5, 2008 correct... Just add an IF testing the Ubound in your loop and have it do an ExitLoop when it has reached it. Jos 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...
PsaltyDS Posted December 5, 2008 Share Posted December 5, 2008 correct... Just add an IF testing the Ubound in your loop and have it do an ExitLoop when it has reached it. Jos Two more possibilities: ; Walk array in reverse For $i = UBound($CIT_list) - 1 To 1 Step -1 If $CIT_list[$i] = $CIT_list[$i - 1] Then _ArrayDelete($CIT_list, $i) Next ; Use Do/Until $i = 1 Do If $CIT_list[$i] = $CIT_list[$i - 1] Then _ArrayDelete($CIT_list, $i) $i += 1 Until $i >= UBound($CIT_list) - 1 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 Link to comment Share on other sites More sharing options...
ds34 Posted December 5, 2008 Author Share Posted December 5, 2008 Thanks for the fast reply. Should make it to the "for" help. 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