LiveCode Support
LiveCode Support

Reputation: 177

How do you save data from a text field to file on iOS and Android from a LiveCode?

I have various text fields within my LiveCode stack that I am trying to save to my mobile device. I have tried various methods but none seem to be working so far. The main script I am using trying to use from a button is-

on mouseUp
  put field "name" into ("file:"&specialFolderPath("engine")&"/name.txt")
end mouseUp

This doesn't seem to be working as if I try dome debugging with -

 on mouseUp
  answer there is a file ("file:"&specialFolderPath("engine")&"/name.txt")
 end mouseUp

It always returns false. Could you give me some pointers to what I am missing from my above script. Thanks.

Upvotes: 0

Views: 600

Answers (2)

Devin
Devin

Reputation: 603

You can't write to the engine folder on mobile devices. You should use the documents folder instead:

on mouseUp
  put field "name" into URL ("file:" & specialFolderPath("documents") & "/name.txt")
end mouseUp

You may also write to specialFolderPath("cache") if the file is only temporary and you don't need it backed up. iOS also gives you the specialFolderPath("temporary") option.

Upvotes: 1

Neil Roger
Neil Roger

Reputation: 691

Both Devin and Mark are correct. The engine folder is not writeable location on mobile and as such, you will need to choose an alternative writable location (e.g. "Documents")

However, changing the path will not fully resolve this issue as the URL Keyword is missing from the script. With this missing, no file will be created and a compilation error will be returned.

A full correct working script would be something like-

put field "name" into url ("file:" & specialFolderPath("documents") & "/name.txt")

Upvotes: 1

Related Questions