Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing in Existing Txt files 1

Status
Not open for further replies.

laado

Programmer
Oct 17, 2002
35
AU
Hi Guys
Is there any way to write to a Existing file.
Currently i am Reading a String then adding my string Erasing the file then Creating a new file and writing a string.

Thanks in Advance
 
Laado,

You approach is ok for relatively small files, there are limits associated with file size and stings and memory availablity - i.e. 64Kb is probably the max you can use
this method for.

You might be better off using the FOPEN, FWRITE and FCLOSE
functions to open the file for APPEND (if it exists), writing one or more new lines and then closing the file.

Code:
*
handle = FOPEN("Temp.txt",2)
*
* Go to the end of the file.
length = FSEEK(handle, 0, 2)
** write to the file (adding a crlf)
FWRITE(handle,"new Line"+chr(13)+chr(10))
** close it
FCLOSE(handle)

Hope this helps
Regards

Griff
Keep [Smile]ing
 
Thanks Griff
I was making mistake when opening file ,i was just opening it ,rather than Open with Append Rights.

Cheers
Yeah i WIll
 
Hi,

Could try,

set device to printer
set printer to yourexistingfile.txt additive

This will add more text to your file.

Jalm

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top