How to store some data in my stack

Klaus on-rev klaus at major.on-rev.com
Wed Jan 25 10:33:43 EST 2012


Konichi-wa Takashi,

Am 25.01.2012 um 16:19 schrieb 吉野 孝:

> Hi,
> 
> I use LiveCode 5.0.2 for Android devices.
> 
> I would like to store some data in my stack.
> But I don't know how to store some data in my stack on an android device.
> 
> At first, I used a field. But the field data is gone at the next launches.
> 
> Next, I tried to use file.
> The following are the  test scripts.
> 
> This is the 'write file' script.
> on mouseUp

## : is the Mac specific path delimiter, and will obviously work on a Mac but nowhere else ;-)

## So ALWAYS use the SLASH as pathdelimiter on ALL platforms:
> ##  put specialFolderPath(“documents”) & ":" & “testFile.txt” into fileName
  put specialFolderPath(“documents”) & "/" & “testFile.txt” into fileName
>    open file fileName
>   write fld "Data" to file fileName

## If you do not psecify a TARGET (like a filed) for the PUT, 
## the output will go into the message box
## which is not available on ANDROID and iOS!
>   put the result
>   close file fileName
> end mouseUp
> 
> This is the 'read file' script
> on mouseUp

## Same here, will work with a SLASH!
>   put  specialFolderPath(“documents”) & "/" & “testFile.txt” into fileName
>   open file fileName
>   read from file fileName until EOF
>   put it into fld "Data"
>   close file fileName
> end mouseUp
> 
> The scripts work on my Mac. 
> But they does not work on an Android device.

See above for the explanation :-)

Hint: you can save some typing by using the short URL syntax (a one-liner):
...
put URL("file:" & specialFolderPath(“documents”) & "/" & “testFile.txt”) into fld "Data"
...

Check URL in the dictionary!

> I need your help.

Now you got it :-)

> _.__ ._ _. ._ ._.__ .. ._._. _._ . ..__ ._.__ ._._. ___. .._ __.. __ .._ 
> Takashi Yoshino 

Best

Klaus

--
Klaus Major
http://www.major-k.de
klaus at major.on-rev.com





More information about the use-livecode mailing list