dofile

From ComputerCraft
Jump to navigation Jump to search

dofile
Function
Syntax
dofile()
Returns whatever the file returns
API Base globals
Source CC:Tweaked

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
ExampleExampleRequire a file from the directory that the currently running program is in
Code
local myFileData = dofile("someFile")
Output Nothing, unless there is an error in someFile