0
votes

I am new to lua and i am trying to make a function that receives documents and outputs a table but I am getting the above error. Why??

io.write("How many documents are we evaluating? \nInput: ")
local total_documents=io.read("*n")
io.read()
local docTable = {}
inputDocument()

function inputDocument()
   local input
   local file
   local inputFile = {filename = nil, contents = nil, wordcount = nil}
   repeat
      io.write("Please enter document (filename.extension): ")
      input = io.read()
      file =io.open(input)
      if file == nil then
         print("File does not exist try again")
      end
   until(file ~=nil)
   inputFile.filename = input
   return inputFile
end
1

1 Answers

1
votes

You need to define inputDocument before using it:

function inputDocument()
   ...
end

io.write("How many documents are we evaluating? \nInput: ")
...
inputDocument()