monica1
22nd November 2005, 18:31
I need to write a text file and at the end of the program I need to write the first line of the file. Is it possible?

I try with this:

......all the code

fp = seq.open(bse.tmp.dir$()&strip$(tfecm007.paths) &"/"& nombre.fichero,"a", ruta)

w = seq.seek(0, 0, fp)

for w=1 to 150 step 1
seq.putc$(linea.csbbk(w;1),fp)
endfor
seq.putc$(chr$(13),fp)
seq.putc$(chr$(10),fp)

seq.close(fp)



How can I do that?

Thank you in advance,

lbencic
22nd November 2005, 18:35
You can try opening with "w" instead of "a". This will allow you to write at your given seq.seek position, but I'm not sure if it over writes or pushes everything down. Give a try and let us know.

monica1
22nd November 2005, 19:05
I try with this but the rest of the lines dissapear.

lbencic
22nd November 2005, 19:09
I was afraid of that.

You may try using seq.write instead of seq.putc...?

If that still does not work, you may have to make a 2nd file, if even temporarily. Put your line in the temp file, then read and add all the other lines from the original file. Close both, move around and rename if you need to then.

Maybe someone else has a better idea.

NPRao
23rd November 2005, 01:16
Refer to the thread -

Unable to append a string at start of the file (http://www.baanboard.com/baanboard/showthread.php?t=10432&highlight=seq.seek)

monica1
23rd November 2005, 12:29
Thank you very much.
Finally I use the 2 files option.