[Solved]io.write() Issues
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Dr.Tyler O.
- Citizen
- Posts: 58
- Joined: Tue Jul 29, 2014 9:17 am
- Location: United States
[Solved]io.write() Issues
First of all, I am aware this doesn't deal directly with love2d but I hope that can be overlooked. I am having issues with the io.write() function. When I attempt to call io.write() to an output file, the information is not written to the file until the application is closed. The program manages to generate the file but fails to insert the string. I have created an example to demonstrate this issue. I am also curious as to whether this is an issue with my computer as opposed to the code.
- Attachments
-
- WritingProblems.love
- You might want to place this in a folder to avoid text document spam.
- (1.49 KiB) Downloaded 101 times
Last edited by Dr.Tyler O. on Tue Aug 04, 2015 3:04 pm, edited 1 time in total.
Any topic I have ever posted that I felt did not require a .love file, although they were requested, never required one so I would appreciate if you did not ask me to supply one unless you think that I am ignorant for not doing so.
Re: io.write() Issues
Try putting io.flush after io.write, that worked for me.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
- Dr.Tyler O.
- Citizen
- Posts: 58
- Joined: Tue Jul 29, 2014 9:17 am
- Location: United States
Re: io.write() Issues
Your solution works but I'm still curious, why do I need to close the file in order to write to it without closing the application?davisdude wrote:Try putting io.flush after io.write, that worked for me.
Any topic I have ever posted that I felt did not require a .love file, although they were requested, never required one so I would appreciate if you did not ask me to supply one unless you think that I am ignorant for not doing so.
Re: io.write() Issues
Because if every time you want to write a single byte to a file, you would need to spin up the HDD, move the writing head into place etc. You would also need to wait for all other prior activity to stop. In order to speed things up there is a buffer system in place, so the actual changes live in the much faster RAM. The contents get flushed when the changes are larger than the buffer size, the application asks the OS to do so (by closing the file) or the application stops running.Dr.Tyler O. wrote:Your solution works but I'm still curious, why do I need to close the file in order to write to it without closing the application?davisdude wrote:Try putting io.flush after io.write, that worked for me.
Who is online
Users browsing this forum: Bing [Bot] and 3 guests