set/get preference file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
set/get preference file
I looked but could not find.
How can I make and get a preference file for IOS?
How can I make and get a preference file for IOS?
Re: set/get preference file
Hi Max,
the same way as on the desktop, maybe in another folder
Read from and write to -> specialfolderpath("documents") & "/your_pref_file_here"
Best
Klaus
the same way as on the desktop, maybe in another folder

Read from and write to -> specialfolderpath("documents") & "/your_pref_file_here"
Best
Klaus
Re: set/get preference file
Thanks, Klaus,
So simple, but not so obvious for me.
Max
So simple, but not so obvious for me.
Max
Re: set/get preference file not working
It works for the Mac, but not ios.
I copied the special folder path folder with the file into the standalone prefs, but this code does nothing. Where did I go wrong?
on closecard
if the environment = mobile
then
open file specialfolderpath("myprefs") & "/PrefsMax"
write ( the number of this card ) to file "PrefsMax"
close file specialfolderpath("myprefs") & "/PrefsMax"
end if
end closecard
on opencard
global NewCardLoc
if the environment = mobile
then
if there is a file specialfolderpath("myprefs") & "/PrefsMax"
then
open file specialfolderpath("myprefs") & "/PrefsMax"
read from file "PrefsMax" at 1 until eof
put it into NewCardLoc
put it into fld "testit" of cd 2
close file specialfolderpath("myprefs") & "/PrefsMax"
end if
end if
end opencard
I copied the special folder path folder with the file into the standalone prefs, but this code does nothing. Where did I go wrong?
on closecard
if the environment = mobile
then
open file specialfolderpath("myprefs") & "/PrefsMax"
write ( the number of this card ) to file "PrefsMax"
close file specialfolderpath("myprefs") & "/PrefsMax"
end if
end closecard
on opencard
global NewCardLoc
if the environment = mobile
then
if there is a file specialfolderpath("myprefs") & "/PrefsMax"
then
open file specialfolderpath("myprefs") & "/PrefsMax"
read from file "PrefsMax" at 1 until eof
put it into NewCardLoc
put it into fld "testit" of cd 2
close file specialfolderpath("myprefs") & "/PrefsMax"
end if
end if
end opencard
Re: set/get preference file
"myprefs" is NOT a valid "specialfolderpath", please check the dictionary if in doubt!
What's wrong with my proposal -> specialfolderpath("documents") ?
P.S.
You might want to use the shorter URL syntax:
...
put specialfolderpath("documents") & "/MinPrefs) into tPrefsFile
## Read:
put url("file:" & tPrefsFile) into fld "Wherever you want to display the prefs..."
...
## Write:
put the num of this cd into url("file:" & tPrefsFile)
...
What's wrong with my proposal -> specialfolderpath("documents") ?

P.S.
You might want to use the shorter URL syntax:
...
put specialfolderpath("documents") & "/MinPrefs) into tPrefsFile
## Read:
put url("file:" & tPrefsFile) into fld "Wherever you want to display the prefs..."
...
## Write:
put the num of this cd into url("file:" & tPrefsFile)
...
Re: set/get preference file
Thank you Klaus
I really like
put the num of this cd into url("file:" & tPrefsFile)
Does that save the number into a permanent file on the ipad? I can not be sure when using the simulator.
Max
I really like
put the num of this cd into url("file:" & tPrefsFile)
Does that save the number into a permanent file on the ipad? I can not be sure when using the simulator.
Max
Re: set/get preference file
Hi Max,
the simulator is also still a mistery to me
Yes, this will save to a "permanent" file on the device itself!
Best
Klaus
the simulator is also still a mistery to me

Yes, this will save to a "permanent" file on the device itself!
Best
Klaus
Re: set/get preference file
I use these three scripts to manage preferences. For example, if I want to write the value "1" to line 3 of the preferences file I call:
setPref 3, "1"
To get the value in line 3 of the preferences file I call:
getPref (3)
The writefile script simply manages the writing of the preferences file to the device.
------------
on setPref whichPref, whatValue
open file specialFolderPath("Documents") & "/prefs.txt"
read from file specialFolderPath("Documents") & "/prefs.txt" until eof
close file specialFolderPath("Documents") & "/prefs.txt"
put whatValue into line whichPref of it
writeFile "prefs", it
end setPref
function getPref lineNumber
open file specialFolderPath("Documents") & "/prefs.txt"
read from file specialFolderPath("Documents") & "/prefs.txt" until eof
close file specialFolderPath("Documents") & "/prefs.txt"
return line lineNumber of it
end getPref
on writefile fileTowrite,dataTowrite
set the defaultFolder to specialFolderPath("Documents")
put dataTowrite into URL (("file:"&fileTowrite&".txt"))
end writefile
Cheers
Gerry
setPref 3, "1"
To get the value in line 3 of the preferences file I call:
getPref (3)
The writefile script simply manages the writing of the preferences file to the device.
------------
on setPref whichPref, whatValue
open file specialFolderPath("Documents") & "/prefs.txt"
read from file specialFolderPath("Documents") & "/prefs.txt" until eof
close file specialFolderPath("Documents") & "/prefs.txt"
put whatValue into line whichPref of it
writeFile "prefs", it
end setPref
function getPref lineNumber
open file specialFolderPath("Documents") & "/prefs.txt"
read from file specialFolderPath("Documents") & "/prefs.txt" until eof
close file specialFolderPath("Documents") & "/prefs.txt"
return line lineNumber of it
end getPref
on writefile fileTowrite,dataTowrite
set the defaultFolder to specialFolderPath("Documents")
put dataTowrite into URL (("file:"&fileTowrite&".txt"))
end writefile
Cheers
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.