loadfile
Takes a filename and will return a function if it's succesful. If it's not, it will return nil and a error message.
| loadfile Function | |
|---|---|
|
Syntax loadfile(
| |
| Returns |
function string |
| API | Base globals |
| Source | CC:Tweaked (source) |
![]()
|
|||
| Code | function executeFile( filename, ... )
local ok, err = loadfile( filename )
print( "Running "..filename )
if ok then
return ok( ... )
else
printError( err )
end
end
executeFile( "doesnotexist.lua" )
executeFile( "rom/programs/id.lua" )
|
||
| Output | Running doesnotexist.lua
File not found
Running rom/programs/id.lua
This is computer #1
|
||
Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Lua |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CC:Tweaked |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.