open remote file in iOS

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
witeowl
Posts: 45
Joined: Mon Feb 21, 2011 3:02 am

open remote file in iOS

Post by witeowl » Tue Feb 22, 2011 3:04 am

I'm a working on a vocabulary game for my students. I have it set right now that vocabulary lists are stored as the CSV contents of fields on a "secret" card. The player selects a list from a menu button, that list's field is "loaded" into the game, and play commences. OK, it works, but as my curriculum changes, it would be much easier to change the vocabulary files on a webpage rather than having to update the app; moreover, I could develop other games which call the same CSV lists.

So, the question is: in an iOS app, is it possible for the player to select from a list of files stored on a webpage and load a CSV file from the webpage?

1) Is it possible?
2) If so, any hints on execution?

Thanks!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: open remote file in iOS

Post by FourthWorld » Tue Feb 22, 2011 4:22 am

It's technically easy to do in LiveCode:

go url "http://www.domain.com/folder/mystack.rev"

You can even shorten download time by using LC's built-in compression.

But that said, I believe the iOS developer agreement prohibits downloading code modules from iOS apps. Not sure how that plays out in your specific scenario, but you may want to review Apple's guidelines before architecting for this.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

witeowl
Posts: 45
Joined: Mon Feb 21, 2011 3:02 am

Re: open remote file in iOS

Post by witeowl » Tue Feb 22, 2011 8:19 am

Thanks for the reply, but I think you misunderstood. I don't want to show a webpage, nor do I want to download an actual code module. I basically want to read (only) information in a text file stored elsewhere. (A comma-separated-value text file.)

I know that other iOS apps access files stored online all the time, and the information stored within them, I just don't know if it's possible through LiveCode.

Basically, I guess I'm asking if I'll be able to do something like this:

Code: Select all

on mouseUp
    set the defaultFolder to specialFolderPath("Documents")
    put URL ("file:iphonetest.txt") into field "read"
end mouseUp
but with the txt file residing somewhere online instead of on the iPod.

Hmmm... As I write this, it really seems like a, "Well of course you can!" question; I guess just want to make sure before I begin pulling my hair out. ;)

Thanks again.

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

Re: open remote file in iOS

Post by Klaus » Tue Feb 22, 2011 12:55 pm

Hi whiteowl,

do this:

Code: Select all

on mouseUp
   put URL ("http://www.yordomain.com/folder1/folder1/your_text_file.txt") into field "read"

   ## When no error occurs, THE RESULT is empty, 
   ##  otherwise contains a string describing the problem
    if the result <> empty then
     answer "There was an error loading the document!" & CR & the result
   end if
end mouseUp
Best

Klaus

witeowl
Posts: 45
Joined: Mon Feb 21, 2011 3:02 am

Re: open remote file in iOS

Post by witeowl » Wed Feb 23, 2011 7:51 am

Thanks, Klaus. That looks like a good way to test before writing too much code. :)

witeowl
Posts: 45
Joined: Mon Feb 21, 2011 3:02 am

Re: open remote file in iOS

Post by witeowl » Sat Feb 26, 2011 8:09 pm

Hmmm... Well, this is weird.

I created a "test" button using the code given by Klaus, edited for the file and field. It works without error in LC, but does absolutely nothing in the simulator. No error, no text in the field, no nothing. Just... nothing.

I can use Safari in the simulator, type the address of the file into the address bar, and Safari loads the list, in case that matters. It's just the LC standalone that doesn't seem to...

Ideas? Thoughts? Alternate solutions?

Post Reply