Page 1 of 1

[Request] Example script of file i/o

Posted: Sat Sep 05, 2009 1:22 pm
by droppen
yeap!

Re: [Request] Example script of file i/o

Posted: Sat Sep 05, 2009 7:21 pm
by Administrator
http://www.lua.org/pil/21.1.html
Also see: http://www.lua.org/manual/5.1/

Code: Select all

local readfile = io.open("filename.txt", "r");
if( not readfile ) then
  error("Something is wrong.", 0);
end

local num, str, line;
num = readfile:read("*n 24 *l");
-- *n means "read a number", 24 means "read a string up to 24 characters long", and *l means "read a whole line as a string"

Re: [Request] Example script of file i/o

Posted: Sat Sep 05, 2009 10:08 pm
by droppen
Oh yeah, didn't know it was a lua function :P

Re: [Request] Example script of file i/o

Posted: Sun Sep 06, 2009 3:52 am
by Rishijin
Where can I look up how to use this function in general?
What you put there still leaves me with several questions, but I won't bother you with them all, considering that they are probably all answered in a manual somewhere.

Re: [Request] Example script of file i/o

Posted: Sun Sep 06, 2009 8:40 am
by 3cmSailorfuku
Rishijin wrote:Where can I look up how to use this function in general?
What you put there still leaves me with several questions, but I won't bother you with them all, considering that they are probably all answered in a manual somewhere.
http://www.lua.org/manual/5.1/

There's a documentation about the functions down there too.

You can also try this: http://luaforge.net/projects/lualangpack/ (I'm not sure if there's a newer version).
It basically integrates LUA into VS2005, including IntelliSense support.

Re: [Request] Example script of file i/o

Posted: Sun Sep 06, 2009 2:27 pm
by Rishijin
Wow I seemed to have missed all of the obvious manuals and links.

I need to stop the insomnia surfing.


Integrating lua into VS sounds very useful, thanks for the link.