Page 1 of 1
DownloadFile() not call callback function
Posted: Wed Oct 19, 2016 10:19 pm
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
Re: DownloadFile() not call callback function
Posted: Thu Oct 20, 2016 1:40 am
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

Re: DownloadFile() not call callback function
Posted: Thu Oct 20, 2016 9:04 am
by Lerio69
Sorry Allanon, but it still does not work
Re: DownloadFile() not call callback function
Posted: Thu Oct 20, 2016 10:41 am
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
Re: DownloadFile() not call callback function
Posted: Thu Oct 20, 2016 11:22 am
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.
Re: DownloadFile() not call callback function
Posted: Thu Oct 20, 2016 11:56 am
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

Re: DownloadFile() not call callback function
Posted: Thu Oct 20, 2016 12:14 pm
by Lerio69
Re: DownloadFile() not call callback function
Posted: Thu Oct 20, 2016 12:23 pm
by Allanon