You can do this by opening the original file for read, and put each line into a
list.
(setq list (cons (read-line RFIL) list)
Then close the read file
Reverse the list, it is backwards
Then open a the file for write (the old file is destroyed, but you have it in
the list
write the lines that are OK to the file
as you cycle through the list you are looking for the line you want to replace
(foreach X list (if (/= TXT RTXT)(write-line X WFIL)(write-line NEWTXT WFIL))
When you get to the replace line, add the new text
continue cycling through the list using write-line
close the file.
The snippets are the guts of what you need to code....
ddk
"Y. Haagsma" wrote:
> I have a question :
> I write an output fil from lisp with severallines.
> Can i overwrite a specific line with new data ??
>
> I know there are a few options for an output file:
>
> r Open for reading.
>
> w Open for writing. If filename does not exist, a new file is created and
> opened. If filename already exists, its existing data is overwritten. Data
> passed to an open file is not actually written until the file is closed with
> the close function.
>
> a Open for appending. If filename does not exist, a new file is created and
> opened. If filename already exists, it is opened and the pointer is
> positioned at the
>
> I can always read first the data and then overwrite the complete file, but
> this is more complicated
>
> Please help
> Ysbrand Haagsma