Jump to content

Using data from an array


Recommended Posts

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

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 by weaponx
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...