kor Posted October 26, 2013 Share Posted October 26, 2013 (edited) I seriously don't understand this. I thought I had arrays and loops down pretty well. Error: adtechscriptsAvigilon.au3 (14) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If StringRegExp($aFolders[$i], "w") Then _ArrayDelete($aFolders, $i) If StringRegExp(^ ERROR All I'm trying to do is loop through a folder list and if any folder contains the $ character delete that line from the array. #include <Array.au3> #include <File.au3> Global $sAvigilonPath = "\\ad\data\avigilon" $aFolders = _FileListToArray($sAvigilonPath, "*", 2) If @error Then ConsoleWrite("! - ERROR - Error reading folder list") _ArrayDisplay($aFolders) For $i = 0 To UBound($aFolders) - 1 ;ConsoleWrite($aFolders[$i] & @CR) If StringRegExp($aFolders[$i], "$") Then _ArrayDelete($aFolders, $i) Next _ArrayDisplay($aFolders) Edited October 26, 2013 by kor Link to comment Share on other sites More sharing options...
Developers Jos Posted October 26, 2013 Developers Share Posted October 26, 2013 You are deleting entries in your array so you need to go from high to low to avoid this issue. 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...
kor Posted October 26, 2013 Author Share Posted October 26, 2013 You are deleting entries in your array so you need to go from high to low to avoid this issue. Jos This doesn't seem to work either For $i = UBound($aFolders) - 1 To 0 Step - 1 Link to comment Share on other sites More sharing options...
Solution kor Posted October 26, 2013 Author Solution Share Posted October 26, 2013 Got it. Working code #include <Array.au3> #include <File.au3> Global $sAvigilonPath = "\\ad\data\avigilon" $aFolders = _FileListToArray($sAvigilonPath, "*", 2) If @error Then ConsoleWrite("! - ERROR - Error reading folder list") _ArrayDisplay($aFolders) For $i = UBound($aFolders) - 1 To 0 Step - 1 If Not StringRegExp($aFolders[$i], "\A[^\W]") Then _ArrayDelete($aFolders, $i) Next _ArrayDisplay($aFolders) 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