Welcome, Guest. Please Login or Register.
eccoMAGIC Forums
05/06/24 at 22:52:47
News: If you have a scroll wheel, TRY EM SCROLL WHEELS. It's NICE!
Home Help Search Login Register


Pages: 1
Send Topic Print
File.close() does not release the file (Popularity: 4882 )
albertschepers
Contributing  Member
***


I Love Ecco!

Posts: 11
Gender: male
Show the link to this post File.close() does not release the file
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.  
Back to top
 
 

Albert Schepers
Email WWW   IP Logged
Admin
Administrator
*****


I love Ecco!

Posts: 134
Show the link to this post Re: File.close() does not release the file
Reply #1 - 12/15/07 at 12:29:52
 
io.output() should return current file handle so,
 
Code:
io.output():close() 


 
 
should force file closed....
 
[untested]
 
Back to top
 
 

The Administrator.
WWW   IP Logged
albertschepers
Contributing  Member
***


I Love Ecco!

Posts: 11
Gender: male
Show the link to this post Re: File.close() does not release the file
Reply #2 - 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
Back to top
 
 

Albert Schepers
Email WWW   IP Logged
Pages: 1
Send Topic Print