DownloadFile() not call callback function

Report any Hollywood bugs here
Post Reply
User avatar
Lerio69
Posts: 29
Joined: Sat Sep 24, 2016 11:47 pm
Location: Italy

DownloadFile() not call callback function

Post by Lerio69 »

Using downloadFile() command I want to update a progress bar. I have create a Button and progress bar using ScuiLib with this two function

Code: Select all

; download button pressed
Function Download1()
	link$="http://www.hollywood-mal.com/download/RapaGUI_Win32.zip"
	DownloadFile(link$, {File = "RapaGUI_Win32.zip", p_CallbackFunc})
EndFunction

; update progress bar
Function p_CallbackFunc(mess)
	level = mess.Count * 100 / mess.Total
	scui.Set("Gauge1", { Value = level }, 1)
EndFunction


The file is downloaded, but the progress bar is not updated, because the callback function is not executed
I'm using Windows 10
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: DownloadFile() not call callback function

Post by Allanon »

Hi Lario69,

I think that it's because you have to define the function before the assignment, in your code you are assigning the variable p_CallbackFunc to the callback when it is not yet defined.

Just copy the function block before the Download() function and it should work :)
User avatar
Lerio69
Posts: 29
Joined: Sat Sep 24, 2016 11:47 pm
Location: Italy

Re: DownloadFile() not call callback function

Post by Lerio69 »

Sorry Allanon, but it still does not work
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: DownloadFile() not call callback function

Post by Allanon »

Are you saying that putting the code this way does not work?

Code: Select all

; update progress bar
Function p_CallbackFunc(mess)
   level = mess.Count * 100 / mess.Total
   scui.Set("Gauge1", { Value = level }, 1)
EndFunction

; download button pressed
Function Download1()
   link$="http://www.hollywood-mal.com/download/RapaGUI_Win32.zip"
   DownloadFile(link$, {File = "RapaGUI_Win32.zip", p_CallbackFunc})
EndFunction
Are you getting errors?

Could you try to add a DebugPrint() to the callback function to check if effectively the callback is not called?

Code: Select all

Function p_CallbackFunc(mess)
   level = mess.Count * 100 / mess.Total
   DebugPrint("Callback says :", level, Mess.Count, Mess.Total)
   scui.Set("Gauge1", { Value = level }, 1)
EndFunction
User avatar
Lerio69
Posts: 29
Joined: Sat Sep 24, 2016 11:47 pm
Location: Italy

Re: DownloadFile() not call callback function

Post by Lerio69 »

Yes I try. No errors, function is not called.
I check documentation to see if I miss something, like and event handler. But this command require nothing. So either it's a bug or is there something in my system that conflicts.
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: DownloadFile() not call callback function

Post by Allanon »

I GOT IT!

Here is the error:

Code: Select all

DownloadFile(link$, {File = "RapaGUI_Win32.zip", p_CallbackFunc})
Must be:

Code: Select all

DownloadFile(link$, {File = "RapaGUI_Win32.zip" }, p_CallbackFunc)
Look at the closing curly bracket ;)
User avatar
Lerio69
Posts: 29
Joined: Sat Sep 24, 2016 11:47 pm
Location: Italy

Re: DownloadFile() not call callback function

Post by Lerio69 »

:shock: Image
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: DownloadFile() not call callback function

Post by Allanon »

:mrgreen:
Post Reply