On 26/06/2020, 02:40, "use-livecode on behalf of William Prothero via
use-livecode" <[email protected] on behalf of
[email protected]> wrote:
Jacqueline:
Thanks for responding. I am really stuck on this.
I can write the file, and get a list of the files I write, but when I try
to read the file using the same code to create the filepaths, etc, the read
routine says the file doesn’t exist. It all works in the dev environment. I had
used a “_” char in the filenames, so I removed it. The read routine can’t find
the file. Very wierd.
I’m going to try to make a very simple test case that I can run on my phone
and post it, but I’m going to take a break. I’ve posted my file reading and
writing code here, but there is probably too much to go through.
Thanks for responding,
Bill
Hi Bill - here's an example script that I use cross-platform (desktop, iOS and
Android) for reading and writing a settings file using
specialFoderPath("documents") on mobile and specialFolderPath("support") on
desktop. In this case the 'settings' are an array that are stored in a
multipurpose global array (gData).
Terry...
global gData
on setPaths
switch environment()
case "mobile"
put specialFolderPath("documents")&"/" into tFolder
break
default
put specialFolderPath("support")&"/myAppName/" into tFolder
if not (there is a folder tFolder) then
create folder tFolder
end if
end switch
put tFolder&"settings.dat" into gData["paths"]["settings"]
end setPaths
on loadSettings
put gData["paths"]["settings"] into tPath
put url ("binfile:"&tPath) into tSettings
if tSettings is not empty then
put arrayDecode(tSettings) into tSettingsA
if tSettingsA is an array then
put tSettingsA into gData["settings"]
else
# invalid settings data
end if
else
# no settings file
end if
end loadSettings
on updateSettings
put gData["paths"]["settings"] into tPath
put gData["settings"] into tSettings
put arrayEncode(tSettings) into tSettings
put tSettings into url ("binfile:"&tPath)
end updateSettings
on clearSettings
put gData["paths"]["settings"] into tPath
if there is a file tPath then delete file tPath
end clearSettings
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode