The eccoMAGIC Forums
http://forums.eccoMAGIC.com/forum/YaBB.pl
the SLANG EXTENSION and Guest Programming >> Bug Reports for Slangmgh >> File.close() does not release the file
http://forums.eccoMAGIC.com/forum/YaBB.pl?num=1197735854

Message started by albertschepers on 12/15/07 at 10:24:14

Title: File.close() does not release the file
Post by albertschepers on 12/15/07 at 10:24:14

For certain routine I open a file for output:

io.output(file,"w+")

this works well deleting any data that might exist from the file and setting it up to write new information.  Once I have the information collected from ecco, using a lua routine, it is written to the file using:

io.write(data)

this also works well.  It is a part of  a loop and all data that is extracted gets written to the file.  Now comes the trick, to close the file so that it may be used elsewhere.  To close the file:

io.close()

is used where the () implies the currently active file, as I understand it.  After this the routine is finished and presumably exited though the file originally opened is locked; it is not possible to delete the file until after ecco is closed.  The file may be opened by other programs such as notepad or the data may be extracted but if the file is deleted an error arises indicating the file is in use.

Either I am using an incorrect command or the lua script is not releasing the file when io.close() is used.  

Could this action be tested and then either correct my understanding or let me know I am not going crazy.

Title: Re: File.close() does not release the file
Post by Admin on 12/15/07 at 12:29:52

io.output() should return current file handle so,


Code:
io.output():close()



should force file closed....

[untested]


Title: Re: File.close() does not release the file
Post by albertschepers on 01/04/08 at 16:47:25

Well I tested this again with my final version and the behaviour that I had mentioned to begin with seems to have corrected itself: the file closes properly now.

I think that I was playing with scripts tht were not complete or faulty and that is why they failed to close the file.  

Anyway the advice was appreciated for this little problem that wasn't.

Albert

The eccoMAGIC Forums » Powered by YaBB 2.1!
YaBB © 2000-2005. All Rights Reserved.