lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On mar. 15 oct. 2002 08:01:48, Gaurav Kumar <gkumar@students.uiuc.edu> 
wrote:

>        I am still in the early stages of learning Lua.
> I am using Lua 3.2. I have this problem, i can read from
> a file , but cannot write to it.
> 
> -- et contains "happy"
> 
> k = openfile("et","r")
> print(k)
> m= read(k,"*l")
> print(m)
> 
>  it works fine
> 
> but this does not ?
> 
> k = openfile("etc","w")
> print(k)
> m= write(k,"happy")
> print(m)
> 
> though a new file is created it has nothing
> 
> and userdata:0 is returned from write.

I fear I can't help you much, but I would raise several points:
- You should indicate the platform on which you are running Lua... Are you 
sure you have the rights to write a file where you want? AFAIK, your code 
will (try to) write the etc file where your script is. You may want to 
specify a path.
- Unless you have a very specific need for it (mandatory at your place?), 
you should probably drop Lua 3.2 to use Lua 4.01. Lua 5.0 is on its way, 
but still alpha as the time of writting. Lua 3.2 isn't bad, of course, but 
a bit outdated and slightly more primitive :-)

-- 
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/