0

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
Diego Pino
  • 11,278
  • 1
  • 55
  • 57

1 Answers1

1

You need to define inputDocument before using it:

function inputDocument()
   ...
end

io.write("How many documents are we evaluating? \nInput: ")
...
inputDocument()
lhf
  • 70,581
  • 9
  • 108
  • 149
  • Sorry for off-topic, @lhf, could you please explain an observation described in Illidan's comment under [that](https://stackoverflow.com/a/48560935/6834680) answer? – Egor Skriptunoff Feb 02 '18 at 07:33