Ask or Answer File on Mobile

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
andyh1234
Posts: 412
Joined: Mon Aug 13, 2007 4:44 pm
Location: Sale UK / FL USA
Contact:

Ask or Answer File on Mobile

Post by andyh1234 » Sun May 24, 2020 3:17 pm

Is there an equivalent to ask or answer file on mobile devices.

I'm working on a PC with Android which is why I posted in Android but assume this applies to both iOS and Android.

I would simple like my users to be able to click a button called 'Import' and then select a text or csv file the app could then read in. I don't need to write out, just give the users an option to select a file and then read it in so I can process it.

Ask and Answer don't seem to do anything.

My code so far is

Code: Select all

on mouseup
   
   put specialFolderPath("documents") & slash into tPath
   set the defaultfolder to tPath
   
   ask file "Select file to import..."
   
   answer "Result" && it && the result
end mouseup
Nothing happens with the ask statement, it just skips it and displays my answer statement.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2564
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Ask or Answer File on Mobile

Post by jmburnod » Sun May 24, 2020 3:35 pm

Hi
On iOS you only can import file from documents folder.
Make un dialog for import something from documents folder is the only way i know. I use a group to display the list of file. The user select one line ans clic on a bun "import" to import it.
Best regards
Jean-Marc

Klaus
Posts: 12207
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Ask or Answer File on Mobile

Post by Klaus » Sun May 24, 2020 3:41 pm

Hi Andy,

what Jean-Marc said!

Due to security reasons we do NOT have access to the filesystem on the mobile platform, neither iOS nor Android!
Create a listfield , fill it with the content of hte DOCS folder and let the user select a file
as Jean-Marc explained in hits posting.

Code: Select all

...
## No need to set the defaultfolder, when we can have/create absolute pathnames!
put files (specialfolderpath("documents")) into tFiles
## Just to be sure, filter out invisible files, if any:
filer tFiles without ".*"
put tFiles into fld "your list field here..."
...
Script of listfield:

Code: Select all

on mouseup
  put the selectedtext of me into tFile
  if tFile = EMPTY then
    exit to top
  end if
  ## No need to set the defaultfolder, when we can have/create absolute pathnames!
  put url("file:" & specialfolderpath("documents") &/" & tFile) into fld "import field"
  ## Or whatever you want to to with that file...
end mouseup
Best

Klaus

andyh1234
Posts: 412
Joined: Mon Aug 13, 2007 4:44 pm
Location: Sale UK / FL USA
Contact:

Re: Ask or Answer File on Mobile

Post by andyh1234 » Mon May 25, 2020 1:34 pm

Thanks Klaus.

Post Reply

Return to “Android Deployment”