1. Re: how to append at the end of file ? (to DAN)

Rolf,

If there *isn't* some file, and you "open" it for reading, and then try to
close it, Euphoria WILL generate an error; that's why it seems best to make
sure to only put the close where you *know* a file opened for reading has
for sure been opened:

<tested code follows:>
-- save this as "TestRead.ex"
atom fhw
fhw = open("TestRead.ex", "r")     -- open a (this) file for reading
if fhw = -1 then     -- shouldn't fail, since it's here
  puts(1,"what, this file isn't here?")
else
  puts(1,"Of course this file is here!")
  close(fhw)  -- closes a for sure open file
end if

puts(1, "\n")  -- make a new line

fhw= open ("NotHere.abc","r")
if fhw = -1 then
  puts(1,"the file NotHere.abc isn't here!")
else
  puts(1,"well, the file NotHere.abc SHOULDN'T be here!")
  -- if you put the close here, it won't generate an error
end if
close(fhw)-- if you leave the close here, it WILL generate an error
               -- because there isn't any file open with the file handle -1
to close

Dan

----- Original Message -----
From: "Rolf Schroeder" <rolf.schroeder at DESY.DE>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Tuesday, December 12, 2000 5:19 AM
Subject: Re: how to append at the end of file ? (to DAN)


> Hello Dan,
>
> you are right in principle you are right, however, 'close' will return
> no error in case the file is allready closed.
>
> Have a nice day, Rolf

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu