Originally posted by Imagine Programming
View Post
Announcement
Collapse
No announcement yet.
Read text file and run as code
Collapse
X
-
Lua 5.1 also has loadfile, which allows for a pure-Lua solution with bytecode support. TextFile.ReadToString stops the string at the first NUL char.
Code:local f, e = loadfile("myfile.lua"); if (type(f) == "function") then f(); else Dialog.Message("error", tostring(e), MB_OK, MB_ICONSTOP); end
-
👍 1
Leave a comment:
-
-
local sFile = TextFile.ReadToString("myfile.lua");
local fCode = loadstring(sFile);
if ( type(fCode) == "function" ) then
fCode();
end
-
👍 1
Leave a comment:
-
-
Read text file and run as code
Is possible to read a text file and run the content as a code?Tags: None
-
Leave a comment: