Hi
My app uses a json file on a server which needs to be downloaded into the app’s caches directory whenever it’s been updated, so I have to get the timestamp of the server file and compare it to the timestamp of the local copy . I have created a PHP script on the server which is called by my app and which returns the timestamp of the json file and puts the timestamp into a var called serverFileTimestamp:
getServerFileTimestamp = function() local URL = "http://www.davidpowell.ca/date\_script.php" network.request( URL, "GET",getServerFileTimestampListener ) end getServerFileTimestampListener = function(event) if ( event.isError ) then print( "Network error!") else local data = json.decode(event.response) serverFileTimestamp = data.lateststamp end end
then I use LFS to get the timestamp of the local copy, which is assigned to a var called locFileTimestamp:
…[start of function…] local file\_path = system.pathForFile( "table\_of\_questions.json", system.CachesDirectory ) local file\_attr = lfs.attributes( file\_path ) locFileTimestamp = file\_attr.modification ...
Now I can use print statements to print the values of these vars to the terminal window.
I can also add them together.
I can also compare them with “==”
But, if I try to see which is greater with this:
if serverFileTimestamp \> locFileTimestamp then … end
I get an error telling me I’m trying to compare a number with a string.
Not sure what’s going on here, so any help much appreciated,
cheers,
david.