Page 1 of 1

How to cancel Upload/Download?

Posted: Wed Jan 20, 2010 1:33 pm
by MasterchiefJB
Hi again,

I got Uploading and Downloading Files working but I would like to provide the User a Button to Cancel the Download/Upload.
How could I do that?


Best Regards,
Masterchief

Re: How to cancel Upload/Download?

Posted: Fri Jan 22, 2010 9:53 am
by Mark
Masterchief,

To answer your question properly, I'd need more information about your approach.

Meanwhile, I can tell you that there is an unload command:

Code: Select all

unload URL "http://www.example.com"
Best,

Mark

Re: How to cancel Upload/Download?

Posted: Fri Jan 22, 2010 3:48 pm
by MasterchiefJB
Well my Application lists all the files of a FTP Server in a listfield. The User can select the file he want to download. He presses the "Download" Button and my app downloads the selected File. And now the user has to wait until my Application finished downloading the file, before he can download another one, so I would like to provide the User with the possability to Cancel the Download while my App is downloading.

I hope this description helps you to understand my problem.
Best Regards,
Masterchief

Re: How to cancel Upload/Download?

Posted: Fri Jan 22, 2010 5:43 pm
by BvG
it probably helps not.

what commad do you use to download the file that you want to cancel. because how (or if) you can cancel it depends of course on how you are doing it :)

Re: How to cancel Upload/Download?

Posted: Fri Jan 22, 2010 6:31 pm
by Mark
Hi BvG and Chief,

You can cancel the download, regardless of whether you use the put url command or a libUrl command.

When you start the download, just store the url somewhere. Use the

Code: Select all

send in x millisecs
syntax in combination with the statusUrl function to poll the download progress regularly. Make sure to look up these commands and functions in the dictionary. You can use the info from statusUrl to update a progress bar.

For an FTP client, I made a window with a list. Each item in the list has a button and a progress bar. If the user presses the button during download, the download is cancelled by the command

Code: Select all

unload URL
I hope this helps.

Mark

Re: How to cancel Upload/Download?

Posted: Fri Jan 22, 2010 9:58 pm
by MasterchiefJB
If the user presses the button during download, the download is cancelled by the command
Thanks BVG and Mark!

@Mark: I am really interested on how to do that. I mean, I want the user to press the button twice, first time starts the download second time it cancels the download, but how do I do that?

Best Regards,
Masterchief

Re: How to cancel Upload/Download?

Posted: Sat Jan 23, 2010 2:14 am
by BvG
for that you need to set a flag for example (for feedback reasons) you could use the label of your button for that:

Code: Select all

on mouseUp
  if the label of me = "" then
    --start download here
    --don't forget to send in 0 seconds, and so on as mark specified
    set the label of me to "cancel"
  else
    --cancel your url here
    set the label of me to ""
  end if
end mouseUp

on urlDone
  set the label of me to ""
end urlDone

Re: How to cancel Upload/Download?

Posted: Mon Jan 25, 2010 6:01 pm
by MasterchiefJB
I am sorry but this point is confusing me as I don“t understand it:
--don't forget to send in 0 seconds, and so on as mark specified
What does it mean?
Best Regards,
Masterchief

Re: How to cancel Upload/Download?

Posted: Sat Feb 06, 2010 12:31 pm
by MasterchiefJB
Hi BvG and Chief,

You can cancel the download, regardless of whether you use the put url command or a libUrl command.

When you start the download, just store the url somewhere. Use the

Code: Select all
send in x millisecs
syntax in combination with the statusUrl function to poll the download progress regularly. Make sure to look up these commands and functions in the dictionary. You can use the info from statusUrl to update a progress bar.

For an FTP client, I made a window with a list. Each item in the list has a button and a progress bar. If the user presses the button during download, the download is cancelled by the command


Code: Select all
unload URL

I hope this helps.

Mark
Hi again,
I was quite busy in the last weeks but now I have time to look into this again. Could anyone please tell me how to write a function that starts if a button is clicked twice? (First Time Starts Download - Second Time Cancels Download)

I know that I have to store the URL and that I have to use the unload URL Command to cancel the download, but how do I write a function that starts when the Downloadbutton is clicked twice?
Thank you very much,
Masterchief