Importing text on IOS

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Importing text on IOS

Post by maxs » Tue Jan 31, 2017 4:27 am

I want to import a list of names from a text file I sent to DropBox to a field my Livecode app.

Livecode dictionary says:
Note: iOS imposes strict controls over what you can and cannot access. Each application in iOS is stored in its own 'sandbox' folder (referred to as the home folder). An application is free to read and write files within this folder and its descendants, but it is not allowed to access anything outside of the 'sandbox'.

It appears that I cannot copy and paste from "Pages" to my app or even import any kind of text file.

Can anyone confirm that this is true. (or has anyone found a workaround?)

Batninja
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 55
Joined: Sat Oct 15, 2011 9:43 am

Re: Importing text on IOS

Post by Batninja » Tue Jan 31, 2017 2:33 pm

Hi

Maybe you can use the MergExt Mergdropbox to access the file directly in Dropbox and save to the local IOS folder?

See details here:

http://mergext.com/home/mergdropbox/

Roger

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Importing text on IOS

Post by Mikey » Tue Jan 31, 2017 3:07 pm

Hey, max, it's a piece of cake, and we have multiple apps that do this.

I personally use the phx_dropbox_lib because it's 100% cross-platform, but for ios only, mergDropbox works great. In either case, you use the library to grab the file, and then you have LC open it. On iOS, every application has a sandbox which includes certain folders that it can access. When you are grabbing files from dropbox, you are just depositing them in that app's sandbox.

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Importing text on IOS

Post by maxs » Sat Feb 04, 2017 6:47 am

Thank you Mikey and Batninja. I appreciate you help.

The documentation for MergDropbox is difficult to understand, and appear to be written for more advanced programmers. It also seems to require the user to imput their account info.

All I want to do is bring a simple textfile into my App.

Here is the code I found for phx_dropbox_lib. Is this correct? If so, How do I install the library?

on mouseUp
if (the uTokenKey of this stack) is empty then
exit mouseUp
end if
put empty into field "flAnswer"
put phx_DropboxGetFileList("sandbox", , ".txt", false) into field "flAnswer"
end mouseUp

Batninja
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 55
Joined: Sat Oct 15, 2011 9:43 am

Re: Importing text on IOS

Post by Batninja » Sat Feb 04, 2017 11:37 am

Hi

Yes the notes are extensive for MergDropBox (@ http://mergext.com/home/mergdropbox/). One way of tackling this is to just get the sample livecode working then tweak the code or remove the parts that are not needed.

It sounds like you want to get files just from your own drop box?
If you do simply wish to get a text file from somewhere into your IOS app then maybe there are other ways of doing this e.g.
  • get from a URL via http
    get from a FTP site
    use iTunes to copy across to the home folder of your app
Maybe describe what and what you are trying to achieve on this thread to see if anyone has another suggestion?

Sorry not to be of any further help.

Roger

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Importing text on IOS

Post by Mikey » Sat Feb 04, 2017 1:44 pm

Both mergDropbox and phx_dropboxLib have example stacks with the packages. phx_dropboxLib is, IMHO more straightforward to get running, so for something simple, maybe that is the one to use. mergDropbox is definitely more "industrial grade".

No matter what service you use, there are authentication/token-obtaining steps that you have to perform. This is the nature of authenticated web services, unfortunately. It is still straightforward.

In neither case do you have to embed your credentials in the app. That is part of the reason why the process can be a little more complicated than just logging in.

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Importing text on IOS

Post by maxs » Sat Feb 04, 2017 5:57 pm

Thank you again Roger and Mikey. I'm appreciative, but sorry to be taking your time and effort on this problem.

I am trying to assist teachers to import a class list of names into my app, so they wont have to manually retype them into the app. Perhaps by having to use authentication/token-obtaining steps for dropbox I am making the problem bigger for myself.

It just seems crazy that a user cannot copy and paste text from one app to another. We can send pictures easily to any app, but not text.

Im curious about getting from a URL via http, could this be a simple solution? Or itunes? If so, how is that done? Max

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Importing text on IOS

Post by Mikey » Sat Feb 04, 2017 6:02 pm

If you want the list of names to be secure then you have to force someone to log in to retrieve them. You can have your app do the importing, OR, the more manual way would be to have the teachers use the Dropbox app, open the file within the Dropbox app, copy the contents, then paste them into your app.

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Importing text on IOS

Post by maxs » Sat Feb 04, 2017 6:15 pm

Hi Mikey

----have the teachers use the Dropbox app, open the file within the Dropbox app, copy the contents, then paste them into your app.


Yes yes yes, that is exactly what I want to do. I tried doing that but I could not get the text file to open. Perhaps I need to find the right text app to assist. I did not think I could copy and paste text from one app to another. I tried copying and pasting text from my Pages app, but nothing saved to the clipboard when I opened my livecode app.

I'll try again.

Max

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Importing text on IOS

Post by Mikey » Sat Feb 04, 2017 6:21 pm

If you double-click the file from within the Dropbox app it should show you the contents. Save the Pages file as plain text before putting it in Dropbox.

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Importing text on IOS

Post by Mikey » Sat Feb 04, 2017 6:22 pm

Also, be aware of the security implications of having student info available to read in a text file that can be accessed without a password...

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Importing text on IOS

Post by maxs » Sun Feb 05, 2017 8:45 am

Hi Mikey,

It worked as you described. I was able to select and copy the text in the dropbox.

But I was unable to paste the text into Livecode.

First, I was unable to open both Livecode and any other app in split windows.
Also, there is no paste commandkey in IOS.
Also, in scripting On mouseenter --paste (or Domenu paste) -- end mouseenter does not work in IOS
Also, the dictionary says Paste does not work with IOS.

Was there a step you know about getting the copied text into Livecode? Max

Batninja
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 55
Joined: Sat Oct 15, 2011 9:43 am

Re: Importing text on IOS

Post by Batninja » Sun Feb 05, 2017 12:09 pm

Hi

Searching through the Livecode site for copy paste IOS produced several hits about how you need to use a native IOS multiline control using mobilecontrolcreate.

I have knocked up a sample stack that shows how this is done. You can paste in text into the field and then get it back out using mobilecontrolget.

Enjoy!
IOS Copy Paste.livecode.zip
Sample creating a mobile text field and getting the contents
(2.06 KiB) Downloaded 347 times
Roger
PS only tested on simulator

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Importing text on IOS

Post by maxs » Sun Feb 05, 2017 9:09 pm

Roger,

Thank you for doing the search in Livecode, finding the answer, and doing the extra step of making a sample stack.

It worked! That was exciting to see. It was one of the things I thought was very difficult to accomplish.

I also learned that I need to look deeper in Livecode myself for answers, as you were able to find many hits. IOS information seems to be spread in a few different places.

Thanks, Max

Post Reply

Return to “iOS Deployment”