Hi chaps,
Can someone help me with Write?
I have a text file which has 4 lines:
ONE=Apples
TWO=Cucumbers
THREE=
FOUR=
I want to find and append to line 3 so that it reads:
ONE=Apples
TWO=Cucumbers
THREE=A lone moose
FOUR=
I have script like this:
Code:
function updatethings()
{
var filestr = "C:\\things.txt"
var myfile = OpenFile(filestr)
if (myfile == null)
{
Debug.trace("Unable to open file" + filestr)
return;
}
else
{
Debug.trace(filestr + " is open" + "\n")
}
while (myfile.EndOfFile() == false)
{
var myrec = myfile.ReadLine();
Debug.trace("Reading record: " + myrec + "\n")
if (String.contains(myrec,"THREE="))
{
Debug.trace("Found THREE!" + "\n")
myfile.Write("A lone moose")//is appending to end of file
//myfile.WriteLine("A lone moose")//is appending to end of file
Debug.trace("Updated: " + myrec + "\n")
}
else
{
Debug.trace("Not THREE" + "\n")
}
wait();
}
}
Both Write and WriteLine are appending to the file.
How do I append to the line?
I'd appreciate any pointers...
Thanks
Melanie
