I’ve written a little word checking module for word game that I’m working on. My problem is, that it works on the Windows Corona simulator… but not on the Mac version of the Corona simulator.
[lua]module(…, package.seeall)
local dictTable = {}
local newTable = {}
function buildDict()
local path = system.pathForFile( “TWL06.txt”)
local file = io.open( path, “r” )
if file then
for line in file:lines() do
dictTable[line] = true
end
io.close( file )
end
end
function checkDictionary(word)
if dictTable[word] then
return(true)
else
return(false)
end
end[/lua]
Everything works as it should right up until I call the checkDictionary function. On the Mac, it will always return false. Similarly, if I do something like print(dictTable[word]), it will return NIL. On the Windows simulator everything works as it should: returning TRUE for words that exist and FALSE for words that don’t.
If I loop through dictTable and print each element (from the checkDictionary function or elsewhere), the output is 100% correct (will print each word in the dictionary)
If I manually insert a word into the dictTable, then I can return that word.
[lua] dictTable[“APPLE”] = true[/lua]
Perhaps writing to a table in this fashion will not work on the Mac version of the Corona simulator?
[lua] dictTable[line] = true [/lua]
Any thoughts anyone? I’m really pulling my hair out on this one! Any help would be greatly appreciated. [import]uid: 65371 topic_id: 11960 reply_id: 311960[/import]