How To Cancel an Ongoing Download

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

How To Cancel an Ongoing Download

Post by endernafi » Sun Dec 23, 2012 1:11 am

Hello Dear LiveCoders,

My question is pretty obvious, I think.
Here is my download and feedback procedure:

Code: Select all


on mouseUp
   put the short name of the target into theClickedObject
   switch theClickedObject
      case "cancelTheDownloadButton"
         /* some code to cancel the ongoing download */
         break
   end switch
end mouseUp

on downloadTheBook
   -- a bunch of control statements to decide whether to download the book
   libUrlDownloadToFile theSource, theTarget
   -- checking the file integrity of downloaded book
end downloadTheBook

on urlProgress pUrl, pStatus, pMessage, pTotalSize
   switch
      case pStatus contains "error"
         set the unicodeText of field "feedbackField" to uniEncode(kErrorMessage, "utf8")
         exit to top
         break 
      case pStatus is "contacted"
      case pStatus is "requested"
         set the unicodeText of field "feedbackField" to uniEncode(kStartingMessage, "utf8")
         break
      case pStatus is "loading"
         put (trunc(pMessage / 1024) & "kb / " & trunc(pTotalSize / 1024) & "kb") into field "feedbackField"
         break
      case pStatus is "downloaded"
         put empty into field "feedbackField"
         break
   end switch
end urlProgress

I want to add a cancellation button to give to user the option to cancel the ongoing download.
I absolutely have no idea how to do this :oops:
Could anyone help me to figure this out?


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How To Cancel an Ongoing Download

Post by Mark » Sun Dec 23, 2012 2:17 am

Hi Ender,

Use the unload URL command.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: How To Cancel an Ongoing Download

Post by endernafi » Sun Dec 23, 2012 2:00 pm

Hi Mark,

Thanks for your quick reply,
but unfortunately unload command doesn't support mobile.

From Dictionary:
Platforms: Desktop, Server and Web
Supported Operating Systems: Mac, Windows, Linux
So, is there any workaround?

I'm open to any ideas 8)


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How To Cancel an Ongoing Download

Post by Mark » Mon Dec 24, 2012 8:46 pm

Hi Ender,

I can't find a way to do this in the dictionary and the release notes. It seems there is no way to do it. I wonder what happens if you'd try to use the rreSockets external to close all sockets (or just those on port 80).

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: How To Cancel an Ongoing Download

Post by endernafi » Mon Dec 24, 2012 8:50 pm

Hi Mark,

Thanks for all your effort and time, you're great :)
I'll think about rreSockets method.
Btw, I've sent an e-mail to the support team.
I'll post their answer here.


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: How To Cancel an Ongoing Download

Post by Jellicle » Sat Mar 02, 2013 12:10 pm

Ender, any answer on this?

Cheers

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: How To Cancel an Ongoing Download

Post by endernafi » Sat Mar 02, 2013 12:19 pm

Hi Gerry,

Unfortunately not.
I've spoken to Neil and he said that there's no way to do that as of now :/

My intention was that
the user should hit the back button
and when he/she goes back, the download cancels automatically.
Well, now I use two buttons; one to cancel download and one to go back.
The cancel button's script has exit to top command.
It cancels the download mostly but not reliable.
I have to content myself with this method...


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

Post Reply