asynchronous download and save with progress problem on iOS

Terry Judd terry.judd at unimelb.edu.au
Tue Jul 24 22:16:29 EDT 2012


Here's the problem - I'm downloading a document (pdf) and displaying a progress bar as I go. When the download is done I then display the document in a viewer. I'm using Monte's mergDoc external for this but I could just as easily be loading it into a browser object.

If I use the synchronous approach - put url pURL into url ("binfile:"&pPath) - then it works fine. My progress bar is updated in a urlProgress handler and when it completes I trap the 'downloaded' message in this handler to display the file.

Now, what I really want to do is to use the load command so that the download isn't blocking. However, if I do this then I get caught up in an endless loop.

If I use a custom message with the load command, like this...

load url pURL with message "pdfdownloaded"

and then in the pdfdownloaded handler do this...

put url pURL into url ("binfile:"&pPath)

Then this kicks off another download and the progress bar goes through its routine again. At the end of this second go the document displays as expected.

If however I don't use a custom message and I trap the 'downloaded' message in the urlProgress handler and try to put the loaded url into the destination file then it kicks off another download, and then at the end of that another - forever.

What am I doing wrong - or is this a Livecode problem?
Has anyone successfully implemented something along these lines that uses load url rather than put url?

Regards,

Terry...


Dr Terry Judd
Senior Lecturer in Medical Education
Medical Eduction Unit
Faculty of Medicine, Dentistry & Health Sciences
The University of Melbourne








More information about the use-livecode mailing list