Synonym for ask file

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am

Synonym for ask file

Post 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
Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Synonym for ask file

Post by Dixie »

Guera,

Code: Select all

put myPrefs into URL("file:" & specialFolderPath("documents") & "/myPrefs.txt")
be well
Dixie
conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am

Re: Synonym for ask file

Post by conde »

Thanks Dixie - but an alert should ask me to type in the file name (like the ask-command).

Guera
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Synonym for ask file

Post 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
conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am

Re: Synonym for ask file

Post 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 :oops:

Thanks in advance ... Guera
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Synonym for ask file

Post 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! :D


Best

Klaus
conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am

Re: Synonym for ask file

Post 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
Post Reply