Page 1 of 1
Synonym for ask file
Posted: Mon Jan 30, 2012 6:37 pm
by conde
Hello,
can anybody help me? What is the synonym in iOS for:
Code: Select all
ask file "Save file as..." with specialFolderPath("Documents")
put it into tSavePath
put myPrefs into url ("file:" & tSavePath)
In other words, save files with a name?
Thanks ... Guera
Re: Synonym for ask file
Posted: Mon Jan 30, 2012 7:48 pm
by Dixie
Guera,
Code: Select all
put myPrefs into URL("file:" & specialFolderPath("documents") & "/myPrefs.txt")
be well
Dixie
Re: Synonym for ask file
Posted: Mon Jan 30, 2012 7:57 pm
by conde
Thanks Dixie - but an alert should ask me to type in the file name (like the ask-command).
Guera
Re: Synonym for ask file
Posted: Mon Jan 30, 2012 8:01 pm
by Klaus
Hi conde,
try this:
Code: Select all
...
ask "Enter a name for the file:"
put it into tFileName
if tFileName <> empty then
## Now save whatever you want to save with that name:
put myPrefs into URL("file:" & specialFolderPath("documents") & "/ & tFileName & ".txt")
end if
...
iOS does not support a direct file access via "answer/ask file..."
Best
Klaus
Re: Synonym for ask file
Posted: Tue Jan 31, 2012 12:12 am
by conde
Hi Klaus,
Yipeee this works fine. Thank you so much.
But sorry - I forget to ask for the v.v. action - the answer command to read my saved file?
Bitte noch einmal Klaus
Thanks in advance ... Guera
Re: Synonym for ask file
Posted: Tue Jan 31, 2012 3:55 pm
by Klaus
Hi guera,
well in principle it is:
Code: Select all
...
put specialFolderPath("documents") & "/ & tFileName & ".txt" into tFile
if there is a file tFile then
put URL("file:" & specialFolderPath("documents") & "/ & tFileName & ".txt") into YourVariable
## do something with YourVariable
end if
...
But since you want to give the user some kind of "open file" dialog, which is not supported on iOS,
this is way more complicated and nothing one could explain here quickly...
You would need to:
1. Memorize all the files that you let the user enter a name for!
Maybe write that info also to a file!?
2. You need to create a custom dialog (modal stack) to let the user select one of his previously saved files
Like a listfield where the user can select a file and an "Open" button
3. Then create the path: specialfolderpath("documents") & "/" & the selectedtext of fld "your list field here"
4. and finally open that file
Get the picture?
Das kommt davon, wenn man dem User zu viel Freihiet lässt!
Best
Klaus
Re: Synonym for ask file
Posted: Tue Jan 31, 2012 4:40 pm
by conde
Klaus - thanks for your great help. I already use your script in my stack for open one txt file.
But between “get the picture" and doing there is a huge gap for me as a beginner.
Thanks for your workaround, but I give up that is out of my range.
Guera