Simucal Posted April 15, 2006 Share Posted April 15, 2006 (edited) I have a For loop with an undetermined To value... $ArraySize = (UBound($SystemDrives)-1) For $i = 1 to $ArraySize If DriveGetFileSystem($SystemDrives[$i]&"\") = "NTFS" Then _ArrayDelete($SystemDrives, $i) $SystemDrives[0] = $SystemDrives[0] - 1 $ArraySize = $ArraySize - 1 EndIf Next However, it seems to just take the initial value of the $ArraySize and that is that. How can I make this loop go through the array until its end, if the size of the array is changing as the loop is running? I keep overstepping the arrays bounds. Edited April 15, 2006 by Simucal AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
greenmachine Posted April 15, 2006 Share Posted April 15, 2006 How bout this: go from $ArraySize to 1 step -1. That way, you're deleting the higher numbered elements first, leaving the lower numbered elements the same. Link to comment Share on other sites More sharing options...
Simucal Posted April 15, 2006 Author Share Posted April 15, 2006 Jeez... Why didnt I think of that?? I'm going to say because its late . This works a treat: For $ArraySize = UBound($SystemDrives) to 1 Step -1 If DriveGetFileSystem($SystemDrives[$ArraySize - 1]&"\") = "NTFS" Then _ArrayDelete($SystemDrives, ($ArraySize - 1)) $SystemDrives[0] = $SystemDrives[0] - 1 EndIf Next Thanks greenmachine. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
greenmachine Posted April 15, 2006 Share Posted April 15, 2006 (edited) Jeez... Why didnt I think of that?? I'm going to say because its late . This works a treat: For $ArraySize = UBound($SystemDrives) to 1 Step -1 If DriveGetFileSystem($SystemDrives[$ArraySize - 1]&"\") = "NTFS" Then _ArrayDelete($SystemDrives, ($ArraySize - 1)) $SystemDrives[0] = $SystemDrives[0] - 1 EndIf Next Thanks greenmachine. It took me a while to figure it out too. I was trying to store it in different variables, or storing the ones to delete in another array and then deleting them afterward (way too complicated, and is more or less the same as you had it), and then I realized ("D'OH") - just do it like I do folds in Scite. If you do it in reverse, the ones you delete only affect the ones you've already passed over. And there you have it, a revelation. Oh, and you're welcome. Edited April 15, 2006 by greenmachine 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