Hello Andreas, here you see how the clueless think ...
I had experimented too, and tried to include the loop in p_DialogFunc(), omitting the "recursive" call to the function via
RunCallback().
As a result, I expected to get the progressbar dialog, but without a working button because WaitEvent is not reached. Instead, it resulted in exactly the behavior amyren described later (empty area instead of button and dialog box that wouldn't close). That's when I let it go for now and didn't reply here because I didn't understand it.
But since we both seem to have done the same things wrong, I wanted to understand what was happening, so now I've tried some more.
amyren: A For loop is unsuitable here, because RapaGUI reacts to events, and it is therefore necessary that WaitEvent is called regularly. I have therefore replaced the variable i with the argument msg.userdata of the function p_DialogFunc(msg).
Instead of the For loop, this function calls itself via RunCallback until userdata reaches the final value (similar to what it does in the original version). This way every single loop pass is called by an event.
If you replace p_DialogFunc() in the original Dialogs.hws with this version, you will have the desired behavior.
The structure is still a bit strange (the function is first called with argument 0, so I set userdata to 1979 first), but you can make this nicer. For example you could use a global variable instead of the function argument. And the three 1979 should also be replaced by a variable or constant.
Code: Select all
Function p_DialogFunc(msg)
If Not msg.userdata>0
msg.userdata=1979
EndIf
; update progress bar
Local progress=(msg.userdata-1979)/(GetDateNum(#DATEYEAR)-1979)*100
moai.Set("prgbar", "level", progress)
If msg.userdata>GetDateNum(#DATEYEAR)
; "loop" finished
p_ShowHideDialog("dlg2", False)
ElseIf abortpressed
p_ShowHideDialog("dlg2", False)
Else
;DebugPrint(msg.userdata)
; (code To download ONE file and save it)
RunCallback(p_DialogFunc, msg.userdata + 1)
EndIf
Wait(20, #MILLISECONDS)
EndFunction
Edit: In the meantime you have also replied. Maybe my example will help anyway.