ksmith247 Posted July 18, 2008 Share Posted July 18, 2008 I seem to be a bit over my head in this one. Thanks to weaponx, I now have a list of file paths/names in an array. I need to open each file (they're plain text) and search for a particular text string. If I find the string, I will probably throw the file out. If I DON'T find the string, I will write the computer name to another file someplace.My question is how do I get each element out of this array? Do I write the array to a file then read the file line by line? Surely not. I have been looking for a way to read the first element (each element is a path to a file), open the file, parse through then move on to the next element. Obviously I am not sure what to look for in the help file. Can someone please point me in the right direction? -Thanks. Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size] Link to comment Share on other sites More sharing options...
weaponx Posted July 18, 2008 Share Posted July 18, 2008 (edited) This is easy stuff. For $X = 0 to Ubound($array)-1 If StringInStr(FileRead($array[$X]),"SEARCH STRING") Then FileDelete($array[$X]) Else EndIf Next Edited July 18, 2008 by weaponx Link to comment Share on other sites More sharing options...
JFee Posted July 18, 2008 Share Posted July 18, 2008 Look at the array information in the helpfile $array[0] gets the first element, $array[1] the second, etc. It is usually a good Idea to have $arrray[0] contain the number of other entries so you know how many times to loop through. Regards,Josh Link to comment Share on other sites More sharing options...
James Posted July 18, 2008 Share Posted July 18, 2008 Something like this: Global $MyArray[4] = [0, 10, 20, 30] $MyArray[0] = UBound($MyArray) - 1 For $i = 1 to $MyArray[0] ConsoleWrite($MyArray[$i] & @CRLF) Next There is probably a better way of doing it though. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
ksmith247 Posted July 21, 2008 Author Share Posted July 21, 2008 This is my first shot at doing something other than ArrayDisplay. Never heard of Ubound before. As usual, it works just fine weaponx. Thanks. Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size] 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