Page 1 of 1

ProgressBar.Value ?

PostPosted: Sat Jan 24, 2015 2:49 am
by bingo
Hello,

Trying to understand how to use AppBuilder, I made a simple project : a ProgressBar and a button with a loop to change the ProgressBar.Value

In the code of the Button, I have put this :

Code: Select all
SetVar [pValue] 0

If [pValue] == 0
   Loop 0 99 [pValue]
        SetAttribute #ProgressBar1 "value" "pValue"
   EndLoop
Else

EndIf


But while expecting to have my ProgressBar increase each time I press the Button, it does it only once (even if I reset the pValue to 0 after each button's click.

Any idea about what I am missing (not understanding) ? Thanks

Re: ProgressBar.Value ?

PostPosted: Sat Jan 24, 2015 5:53 am
by PaulTomo
Gave this a try and I get the same results.

If you add an extra button and set the value to 0 by clicking that first it will then run the progress bar again but I don't think it actually does what you are expecting it to.

It appears to me that the Loop is taking priority as it is run, then once it has, the progress bar just fills as if you clicked the button with the value set to its max.
If you just add this to the button, you get the exact same result on screen as the code runs that you see with the Loop example.
Code: Select all
SetVar [pValue] 100



I tried it with a 1 second Delay added in just after the variable is set back to "0" to see if I could stop the loop from running to quick on the second button press and hopefully giving the "pValue" more of a chance to set it's self back to "0"

Code: Select all
SetVar [pValue] 0
Delay 1000
If [pValue] == 0
   Loop 0 99 [pValue]
        SetAttribute #ProgressBar1 "value" "pValue"
   EndLoop
Else
EndIf


Unfortunately this through up an error of it's own and the code then failed to run, looks like the Delay function has it's own bug!
ReferenceError. "delay" is Undefined

Another couple of things here it seems for the team to take a look at.

Re: ProgressBar.Value ?

PostPosted: Sat Jan 24, 2015 6:10 am
by djmarkes
Try:

Code: Select all
SetVar [pValue] 0
Delay 1000
If [pValue] == 0
   Loop 0 99 [pValue]
        SetVar [ValueProgress] "[pValue]"
   EndLoop
Else
EndIf


And paste the [ValueProgress] variable in the value of the property value.

Re: ProgressBar.Value ?

PostPosted: Sat Jan 24, 2015 7:44 am
by Gaev
Bingo, PaulTomo:

Yes, the Delay command does not appear to work ... but I don't know if it would solve your dilema.

There is nothing wrong with your code per se ... but the Progress Bar object is being rendered ONLY at the end of the event routine ... so if you do this ...
Code: Select all
SetVar [progressValue] 0
Loop 0 5 [progressValue]
   SetVar [ProgressBar1Value] "[progressValue]"
   jsAlert "[progressValue] ... [ProgressBar1Value]"
EndLoop

... you can see that the rendering takes place at the end of the loop ... so, when it is already at 5 (100 in your case) ... and at the end of the second/subsequent clicks of the button, you want it to be 'the same value', you do not see the progress.

I created a separate button with code ...
Code: Select all
SetVar [ProgressBar1Value] 0

... and if you click the 2 buttons alternatively, you can see that the code works as expected.

So, the question (for Dave) is ... how does one cause a Refresh (rendering) of the Object during an event routine ? ... I think the Delay command won't do it ... may have to start a Timer (javascript: setInterval() or setTimeout() ) ... and have the updates to the [ProgressBar1Value] variable done in each Timer event.

Re: ProgressBar.Value ?

PostPosted: Mon Jan 26, 2015 11:52 am
by Neosoft Support
I think we'll probably need some type of dedicated refresh action to force the browser to update the display. Setting a variable in JavaScript doesn't automatically trigger a screen refresh and we probably wouldn't want it to because it would be very slow.