[Request] Example script of file i/o

You may request or share scripts for MicroMacro in this forum.
Post Reply
Message
Author
User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

[Request] Example script of file i/o

#1 Post by droppen »

yeap!
User avatar
Administrator
Site Admin
Posts: 5340
Joined: Sat Jan 05, 2008 4:21 pm

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

#2 Post 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"
User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

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

#3 Post by droppen »

Oh yeah, didn't know it was a lua function :P
User avatar
Rishijin
Posts: 49
Joined: Sat Jul 04, 2009 4:25 pm
Location: Kauai

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

#4 Post 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.
User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

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

#5 Post 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.
User avatar
Rishijin
Posts: 49
Joined: Sat Jul 04, 2009 4:25 pm
Location: Kauai

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

#6 Post 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.
Post Reply