how to append at the end of file ? - thanks !
- Posted by "Gottwald, IT-IS T500, Fa. Compaq, DA" <T.Gottwald at DEUTSCHEPOST. Dec 12, 2000
- 454 views
------_=_NextPart_000_01C0643C.5E570330 charset="iso-8859-1" Thanks Rolf & Jiri (& Ray !), I got it ! That was really a funny mistake ! If I do not close the file, I can append to the file at the beginning ! We can treat this file as closed now and this experience as a feature (its not a bug ...). -- Theo ----- Original Message ----- From: jiri babor <jbabor at PARADISE.NET.NZ> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Tuesday, December 12, 2000 11:56 PM Subject: Re: how to append at the end of file ? > Theo, > > Your mistake was *not closing* the file before reopening it again with > the second call of your function. > > Unfortunately, your function does not save the file handle. I have > slightly modified your function to return the handle and to allow you > to > close the file. > > jiri > > > -- test -------------------------------------------------------------- > > include file.e > > constant Logfile = "test.dat" > integer ok > > global function t_appndf(sequence fn,object t) > atom fhw > > fhw = open(fn,"a") > if fhw = -1 then > puts(1, "Error: couldn't open file" & fn & "!\n") > abort(1) > else > puts(fhw,t) > end if > return fhw > end function > > -- So now you can call it: > > ok = t_appndf(Logfile,"startet\n") > close(ok) > > -- And again: > > ok = t_appndf(Logfile,"ended\n") > close(ok) ------_=_NextPart_000_01C0643C.5E570330 name="Gottwald, IT-IS T500, Fa. Compaq, DA.vcf"