dofile

Loads and then runs a file, using loadfile. The following is what the internals of this function look like:

function dofile(fileName)
  local f = assert(loadfile(fileName))
  return f()
end
ExampleRequire a file from the directory that the currently running program is in
Code
<nowiki>
local myFileData = dofile("someFile")
</nowiki>
Output Nothing, unless there is an error in someFile

dofile
Function
Syntax
dofile(
  • filename : string
)

Returns whatever the file returns
API Base globals
Source CC:Tweaked (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.