thx
Forum




create file
12 replies



thx
1
2
3
2
3
local file = io.open("my.file", "w") file:write("This is my file") file:close()
This would create a file and write This is my file to it. You should make sure you have write rights in the folder though.
nil at file:write
weird?
Well, there are several forms, but this is the one i use.



EDIT: LOL, i was thinking you want to cretae a .lua file

just, how do i make it create a file io.open gives nil when file doesent exist
The reason this code is not working is because you are not opening it with the right rights or the file does not exist.
Well that is what I remember. But yeah, give more details about the error message.
The exact code below creates a file called my.file with This is my file as contents on my Ubuntu 10.10. So the problem must lie within your system configuration.
You should try using the assert function for an error report:
1
local file = assert(io.open("my.file", "w"))
Hmmm, it must be PHP then. I started learning them right about the same time, so I might of confused some stuff around


maybe its cause im missing a folder, i was tinking it would create it?
edit: yeah working now, thx
edited 1×, last 05.03.11 12:03:20 pm



