Re: how to append at the end of file ?
- Posted by Ad Rienks <kwibus at ZONNET.NL> Dec 12, 2000
- 480 views
Hallo Theo, It is easy. The crucial thing is to close your file again before appending a second item: -- Append2File.ex global function t_appndf(sequence fn, object t) atom fhw,r fhw = open(fn,"a") if fhw = -1 then r = 0 else r = 1 puts(fhw, t) end if close(fhw) -- this is necessary! return r end function -- So now I call it: object ok, Logfile Logfile = "test.dat" ok = t_appndf(Logfile, "started\n") ok = t_appndf(Logfile, "ended\n") -- EOF Append2File.ex Ad Rienks ----- Oorspronkelijk bericht ----- Van: Gottwald, IT-IS T500, Fa. Compaq, DA <T.Gottwald at DEUTSCHEPOST.DE> Aan: <EUPHORIA at LISTSERV.MUOHIO.EDU> Verzonden: dinsdag 12 december 2000 12:14 Onderwerp: how to append at the end of file ? > If I believe in the Documentation .. its easy: > "Output to a file opened for append will start at the end of file. " > Let's try this under Win2k: > > global function t_appndf(sequence fn,object t) > atom fhw,r,f > fhw = open(fn,"a") > if fhw=-1 then r=0 else r=1 > puts(fhw,t) > end if > return r > end function > > So now I call it: > > ok=t_appndf(Logfile,"startet\n") > ok=t_appndf(Logfile,"ended\n") > > Now lets look at the resulting Logfile: > " > ended > startet > " > Oh no - it "appended things" at the beginning of the file ! > Whats my mistake here ? > > PS: Sent a short copy of the mailto:atp at c10.de thanks > > --Theo Gottwald > http://www.theogott.de > mailto:atg at theogott.de > >