Delay, break in the loop

127 views
Skip to first unread message

Patryk F

unread,
Mar 6, 2019, 5:07:37 PM3/6/19
to MIT App Inventor Forum
Is it possible to make a delay, break in the loop? During the delay, the program does not have to do anything, it only has to start after the set time.

TimAI2

unread,
Mar 6, 2019, 5:47:05 PM3/6/19
to MIT App Inventor Forum
Use a clock timer in order to wait

See waiting and timing in part II of the FAQ

There is also a "break" block in the Control section of the blocks editor to help you break out of a loop, based upon conditions

From what you say, start the loop, break (record position of break in loop), start the clock, continue the loop in the clock timer (call another procedure with same blocks, using the break point as the starting point)
Or whatever you intend....

Patryk F

unread,
Mar 7, 2019, 4:24:01 PM3/7/19
to MIT App Inventor Forum
I read and can not understand it or I do not see the use of it. Maybe I'll write what I want to do. The program has to process the list. Each element of the list up to 16bit 1 and 0. The element of the list may also be the pause time which is to stop the list processing and after this time the processing is to be continued. I enter data in the text field, after pressing the button, the data is processed and sorted into three lists: "start", "loop" and "end". Then, the elements of the "start" list are processed first, then the elements of the "loop" list are processed. I want to have an outside influence on the loop processing that it has to be done once or several times. Finally, the "end" list should be processed. Well, the program has something to do by reading data from the list and when it hits, for example, "pause 100ms", it has to stop for 100ms, and then move on. I would like an effect like in C ++ "delay ()". Do you have any idea or idea how to do it differently? I found the extension of Juan Antonio delay relating to the list. But I do not understand it.

TimAI2

unread,
Mar 7, 2019, 5:28:36 PM3/7/19
to MIT App Inventor Forum
On reflection you do not need to use the break block, but use two clocks and counters

Here is an example that works through a list of letters in the alphabet, and waits twice during the loop

I attach a video and an aia

BLOCKS

blockswait.png


Does this help you ?


out-2.ogv
wait.aia

Patryk F

unread,
Mar 7, 2019, 5:43:00 PM3/7/19
to MIT App Inventor Forum
I need to analyze the blocks but the video looks ok. For me, data processing is to be as fast as possible without delays. Here, the list reading is probably every 1 second. Only delay 1, 2, 3, 4, 5 is to be a regulated delay.

TimAI2

unread,
Mar 7, 2019, 5:53:32 PM3/7/19
to MIT App Inventor Forum
AI2 will start to struggle if you get down to clock times of @ 50ms

Taifun

unread,
Mar 17, 2019, 9:37:58 PM3/17/19
to MIT App Inventor Forum
as Tim already suggested, use a clock component

Taifun

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

Patryk F

unread,
Mar 18, 2019, 1:44:09 PM3/18/19
to MIT App Inventor Forum
My problem is that I need an adjustable delay eg from 50ms to 1000ms. But the delay would have to be with a small error, say + -50ms. Can I make such a small delay with such accuracy? It seems to me that the processor on the phone is fast enough to do it?

Taifun

unread,
Mar 18, 2019, 2:23:24 PM3/18/19
to MIT App Inventor Forum
read again my previous answer and use a clock component, then try something
the timer interval can be a vaule of your choice

Taifun
Reply all
Reply to author
Forward
0 new messages