file read/write question

Hi,

I write out an integer to a file like this:

local halfSpeed = 3
file:write( tostring( halfSpeed ), "\n" )

Later I read it in:

halfSpeed = file:read()
print("halfSpeed = ",halfSpeed) -- it prints out 3
if halfSpeed == 3 then
print("got to here") -- this fails
end
halfSpeed = math.floor( halfSpeed )
if halfSpeed == 3 then
print("got to here") -- this works
end

It appears that Lua thinks it read in a floating point value?
Am I missing something?
Thanks all,
-Dennis

views:1453 update:2012/1/9 8:53:30
corona forums © 2003-2011