Page 1 of 1

How to write inside files

Posted: 13.09.2008, 21:04
by rinoa79
Hi,
I'm learning to write files via celestia with the "io.open()"
using the function that is on page
viewtopic.php?f=9&t=8326 but nothing happens.
He says that Celestia wrote the file but there isn't anything in the file. 8O
I can not understand what is wrong... :?:
Someone can help me?
Thanks in advance!

Re: How to write inside files

Posted: 14.09.2008, 11:37
by selden
It works fine for me under Windows XP SP3 using Celestia v1.5.1.

Here's the minimal example code, leaving out the on-screen display and writing to Celestia's extras directory

Code: Select all

celestia:requestsystemaccess()
myfile = io.open("extras/test.txt","w")

text = "Hello, Universe!"
myfile:write(text)
myfile:close()


First it asks if you want to allow I/O operations.
Then the file text.txt is created in Celestia's extras folder on my computer. It contains the string
Hello, Universe!

Re: How to write inside files

Posted: 14.09.2008, 11:52
by rinoa79
selden wrote:It works fine for me under Windows XP SP3 using Celestia v1.5.1.

Here's the minimal example code, leaving out the on-screen display and writing to Celestia's extras directory

Code: Select all

celestia:requestsystemaccess()
myfile = io.open("extras/test.txt","w")

text = "Hello, Universe!"
myfile:write(text)
myfile:close()


First it asks if you want to allow I/O operations.
Then the file text.txt is created in Celestia's extras folder on my computer. It contains the string
Hello, Universe!


Your code works. I don't know why the other not!
I'm starting to yours!
thank you very much!
:D