PDA

View Full Version : Lua and IO file



shura_k
December 24th, 2002, 12:50 AM
Why i can't read and write file in LUA script?
In original LUA it's support.

Ron
December 25th, 2002, 12:30 PM
Must work in girder too.

shura_k
December 26th, 2002, 12:21 AM
Ok. it's work.

function readfile(name)
local f = openfile(name, "r")
local s = read(f, "*a")
closefile(f)
return s
end

local t=readfile("c:\\shut.txt")
print(t)

Darbour1
December 29th, 2002, 06:36 PM
Hi,

Could anyone please help me !!!

I am trying to send the content of LUA variables to Girder but it does not work.

Here is the sample code I am using, but the "t" variable is not accessible from within girder???, "t" is the content of the file c:\shut.txt in the example below. :(

Thanks very much in advance for your help,
Dan

function readfile(name)
local f = openfile(name, "r")
local s = read(f, "*a")
closefile(f)
return s
end
local t=readfile("c:\\shut.txt")
print(t)

Darbour1
December 29th, 2002, 06:52 PM
Please forget my previous posting, I found the answer!!!

I managed to find a copy of the Lua manual and on page 1 of the book it is mentionned that by default all variables are global and therefore are available in girder if you remove the word Local !!!!

Dan