DownloadFile() not call callback function

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

DownloadFile() not call callback function

Post by Lerio69 » Wed Oct 19, 2016 10:19 pm

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: 464
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: DownloadFile() not call callback function

Post by Allanon » Thu Oct 20, 2016 1:40 am

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 :)
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
Lerio69
Posts: 15
Joined: Sat Sep 24, 2016 11:47 pm
Location: Italy

Re: DownloadFile() not call callback function

Post by Lerio69 » Thu Oct 20, 2016 9:04 am

Sorry Allanon, but it still does not work

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

Re: DownloadFile() not call callback function

Post by Allanon » Thu Oct 20, 2016 10:41 am

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
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
Lerio69
Posts: 15
Joined: Sat Sep 24, 2016 11:47 pm
Location: Italy

Re: DownloadFile() not call callback function

Post by Lerio69 » Thu Oct 20, 2016 11:22 am

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: 464
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: DownloadFile() not call callback function

Post by Allanon » Thu Oct 20, 2016 11:56 am

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 ;)
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
Lerio69
Posts: 15
Joined: Sat Sep 24, 2016 11:47 pm
Location: Italy

Re: DownloadFile() not call callback function

Post by Lerio69 » Thu Oct 20, 2016 12:14 pm

:shock: Image

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

Re: DownloadFile() not call callback function

Post by Allanon » Thu Oct 20, 2016 12:23 pm

:mrgreen:
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

Post Reply