

Any help would be appreciated

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Code: Select all
on preOpenStack
if the environment is not mobile then exit preOpenStack
put specialFolderPath("documents") & "/appState.txt" into tStatePath
if there is not a file tStatePath then
## Create and populate the State.txt file
open file tStatePath for write
write "1002" to file tStatePath -- pre-populate the txt file with the ID of cd 1
close file tStatePath
else
-- answer "There is a file appState.txt"
end if
## Restore the state of the Last Card opened
set the defaultFolder to specialFolderPath("Documents")
put line 1 of URL ("file:appState.txt") into tStateCardID
put line 3 of URL ("file:appState.txt") into tSelection
set the uCollection of this stack to line 4 of URL ("file:appState.txt")
set the uMainFolder of this stack to line 5 of URL ("file:appState.txt") -- "/B1/"
set the uHeaderField of this stack to line 6 of URL ("file:appState.txt") -- "Pre WWII Soldiers"
set the usubHeaderField of this stack to line 7 of URL ("file:appState.txt")
end preOpenStack
on shutdown
## set default folder to writeable directory on mobile
set the defaultFolder to specialFolderPath("Documents")
put the uCollection of this stack into line 4 of URL ("file:appState.txt")
put the uMainFolder of this stack into line 5 of URL ("file:appState.txt")
put the uHeaderField of this stack into line 6 of URL ("file:appState.txt")
put the usubHeaderField of this stack into line 7 of URL ("file:appState.txt")
pass shutdown
end shutdown
Hi Tomquailcreek wrote:Yep... absolutely works in iOS. I use it all the time. Remember to pass shutDown
Code: Select all
on preOpenStack if the environment is not mobile then exit preOpenStack put specialFolderPath("documents") & "/appState.txt" into tStatePath if there is not a file tStatePath then ## Create and populate the State.txt file open file tStatePath for write write "1002" to file tStatePath -- pre-populate the txt file with the ID of cd 1 close file tStatePath else -- answer "There is a file appState.txt" end if ## Restore the state of the Last Card opened set the defaultFolder to specialFolderPath("Documents") put line 1 of URL ("file:appState.txt") into tStateCardID put line 3 of URL ("file:appState.txt") into tSelection set the uCollection of this stack to line 4 of URL ("file:appState.txt") set the uMainFolder of this stack to line 5 of URL ("file:appState.txt") -- "/B1/" set the uHeaderField of this stack to line 6 of URL ("file:appState.txt") -- "Pre WWII Soldiers" set the usubHeaderField of this stack to line 7 of URL ("file:appState.txt") end preOpenStack on shutdown ## set default folder to writeable directory on mobile set the defaultFolder to specialFolderPath("Documents") put the uCollection of this stack into line 4 of URL ("file:appState.txt") put the uMainFolder of this stack into line 5 of URL ("file:appState.txt") put the uHeaderField of this stack into line 6 of URL ("file:appState.txt") put the usubHeaderField of this stack into line 7 of URL ("file:appState.txt") pass shutdown end shutdown
Code: Select all
...
## Restore the state of the Last Card opened
set the defaultFolder to specialFolderPath("Documents")
put line 1 of URL ("file:appState.txt") into tStateCardID
put line 3 of URL ("file:appState.txt") into tSelection
set the uCollection of this stack to line 4 of URL ("file:appState.txt")
set the uMainFolder of this stack to line 5 of URL ("file:appState.txt") -- "/B1/"
set the uHeaderField of this stack to line 6 of URL ("file:appState.txt") -- "Pre WWII Soldiers"
set the usubHeaderField of this stack to line 7 of URL ("file:appState.txt")
...
Code: Select all
...
## set the defaultFolder to specialFolderPath("Documents")
## Why messing with the default folder when you can have an absoulte pathname:
put specialFolderPath("documents") & "/appState.txt" into fPrefsFile
put url ("file:" & tPrefsFile") into tPrefs
put line 1 of tPrefs into tStateCardID
put line 3 of tPrefs into tSelection
set the uCollection of this stack to line 4 tPrefs
set the uMainFolder of this stack to line 5 of tPrefs
set the uHeaderField of this stack to line 6 of tPrefs
set the usubHeaderField of this stack to line 7 of tPrefs
...