What the heck? Writing and reading ios files??

prothero at earthlearningsolutions.org prothero at earthlearningsolutions.org
Wed Jun 24 20:35:55 EDT 2020


Folks:
I’m having a very weird problem writing then reading the same file on ios. I must be missing something very basic. I’ve checked the path to the file when it is written and it matches exactly to the path when I try to read it. In the read routine, I check for the file’s existence and it says it doesn’t. But when I write the file and immediately check for the file’s existence (in the same handler), it says it exists. I’ve checked the path with the debugger and the path it writes to is exactly the same as the path it looks for the file in.

I must be missing something very basic. It works on my dev system, but in the phone, it can’t find the files it just wrote. Is there some kind of permission needed? I’m stumped.

Please enlighten me. There must be some really, really basic thing I’m missing. 

Thanks,
Bill

--retrieves an arbitrary array from the waterdetective local storage folder

function getArrayFromLocal fName

put getPathToUserDocuments() into tFloc

put tFloc&"/"&"waterdetective/"&fName into tFile

if the last char of tFile is cr then

delete the last char of tFile

end if

—It can’t find the file I just wrote
if there is a file tFile then

put URL ("binfile:"&tFile) into temp

put base64decode(temp) into temp

put arrayDecode(temp) into tArray

else

return ""

end if

return tArray

end getArrayFromLocal


function getPathToUserDocuments

put specialFolderPath("Documents") into tPath

return tPath

end getPathToUserDocuments

on saveArrayToLocal fName,tArray

if fname contains "meterReadingsA" then

breakpoint

end if

--put tNameExt after fName

if the last char of fName is cr then

delete the last char of fName

end if

put getPathToUserDocuments() into tFloc

put tFloc&"/"&"waterdetective" into tFolder

checkCreateFolder tFolder

put tFolder&"/"&fName into tDataFile

delete file tDataFile

put arrayEncode(tArray) into temp

put base64encode(temp) into tData

put tData into URL ("binfile:"&tDataFile)

wait 2 seconds

if there is a file tDataFile then

put "Yes" into x   —on ios I get “Yes"

put tDataFile into theLocalPath

else

put "No" into x

end if

end saveArrayToLocal

William A. Prothero
Santa Barbara, CA. 93105
http://earthlearningsolutions.org/




More information about the use-livecode mailing list