Label and Button Text does not update during a do loop

358 views
Skip to first unread message

Greg Marsh

unread,
Jul 18, 2014, 1:02:48 PM7/18/14
to mitappinv...@googlegroups.com

During the do loop test program shown below the the text Label1 and Button1 does not change until beat 6 is done, and then 6.0 and here2 is displayed. I tried both emulator and downloading the program to the phone. Is there a way to get button or label text to update during a do loop?




Taifun

unread,
Jul 18, 2014, 1:06:31 PM7/18/14
to mitappinv...@googlegroups.com
use a clock component instead of a for each loop

also, why do you need the while loop? see also

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

Greg Marsh

unread,
Jul 18, 2014, 2:16:42 PM7/18/14
to mitappinv...@googlegroups.com
Previously did a metronome app with a clock timer component that worked pretty good, but was trying to eliminate timer variations with a while loop using the clock duration function. Actually this does seem to eliminate time variations, but labels are not updating. - Greg

Taifun

unread,
Jul 18, 2014, 3:15:33 PM7/18/14
to mitappinv...@googlegroups.com
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Greg Marsh

unread,
Jul 18, 2014, 6:08:16 PM7/18/14
to mitappinv...@googlegroups.com

Here is a partial screenshot of the 98% working metronome app - when set to say 100 bpm it is accurate plus or minus 2 bpm. Just a timer call that displays a label and plays sounds. I'm thinking about trying to run the Timer a little fast and then having a clock duration call to wait to the exact time. - Greg M 


metronomeRef.png

Taifun

unread,
Jul 18, 2014, 7:05:02 PM7/18/14
to mitappinv...@googlegroups.com
the last screenshot does not help to find a solution for your problem...

as already said, if you want the label to update, use a clock component instead a for each loop and a counter variable wich increments after each run of the timer event, if you want to see the label updating, try some different timer intervals, e.g. 10 milliseconds

Taifun

Taifun

unread,
Jul 18, 2014, 7:11:51 PM7/18/14
to mitappinv...@googlegroups.com
here is a quick example
Taifun


Taifun

unread,
Jul 18, 2014, 7:12:21 PM7/18/14
to mitappinv...@googlegroups.com
see attached project
Taifun
count.aia

Greg Marsh

unread,
Jul 21, 2014, 1:03:50 PM7/21/14
to mitappinv...@googlegroups.com
Got it working, replaced 1st do loop with a timer set for 30ms, in the timer have empty do until clock duration timer start - now < beat interval * beat count, and after that have the play the metronome sound. No drift off time.
Reply all
Reply to author
Forward
0 new messages