How to obtain a time delay within a loop

Wish a happy and constructive new year to the community.

I am trying to activate a Clock1.Timer to obtain a delay within a loop, so loops will execute in delay one after the other. What I get is the execution of loops at once, that means blocks Clock1.TimerEnabled and Clock1.Timer (see image) are not reached.

I noticed the comment How to create a 400 ms message which disappeared of @Kanishka_Developer in post #6. It assumes that delay within a loop is not performed.

Is there any other technique to obtain this delay?
I post blocks which fail to display output in steps of time interval. The output is 1-2-3-4-5- immediately.

Thanks in advance.

1 Like

Happy new year to you too! You’re enabling the Clock1.Timer 5 times in succession, in the for-loop. You’d have to put the Label1 blocks in the Timer event. Sadly, there seems to be no easy way to wait in a loop.

1 Like

Moving the Label1 blocks in the Timer event produces just delay of 1s.

In Delphi Pascal is a method named Application.ProcessMessages which allows the app to update changes in components (such as set label text, recolour text etc.), especially useful within long loops. I have not found something similar here.

Anyway, thank you for your reply.

What did you want…? :sweat_smile:

1 Like

You can use that extension to wait in a loop before executing the next item.


Extension file


Thank you very much. The proposed example works perfectly. I will try it in my app.

1 Like

You are welcome :+1:t5:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.