Sign in to follow this  
Followers 0
archies

_FileReadToArray and then "Find and Replace text" ?

3 posts in this topic

#1 ·  Posted (edited)

Hey guys,

Say I have this test.txt file:

The dog catcher chased the dog down the street.
The dog chased the cat down the street.
The cat chased the mouse down the street.
The mouse got away from the cat.
The cat got away from the dog.
The dog got away from the dog catcher

Ok now I want to read this file into an array so:

#include <File.au3>
Dim $MyArray
_FileReadToArray(c:\test.txt, $MyArray)

I'm not sure what the "Dim" thing is for but I've seen it used when someone else helped me the other day with another problem so I'm assuming it is needed.

Anyways, now I want to perform a couple of operations on "$MyArray" and one of them is to do some basic "find and replace" text.

So for this example, I want to replace the word "street" with the word "road" in the whole "$MyArray". And also the word "got" with the word "ran".

So if I were to do a _FileWriteFromArray at this point, I would get a txt file that looks like this:

The dog catcher chased the dog down the road.
The dog chased the cat down the road.
The cat chased the mouse down the road.
The mouse ran away from the cat.
The cat ran away from the dog.
The dog ran away from the dog catcher

Hope it's all clear.

Thanks for the help guys!

PS: I tried to do StringReplace($MyArray,street,road) but it seems to have no affect :P

Edited by archies

Share this post


Link to post
Share on other sites

Awesome! thanks so much man!

I was close to figuring it out on my own but I knew something I was doing had to be wrong.

Thanks man :P

Share this post


Link to post
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
Sign in to follow this  
Followers 0