Using Beta 4
One of my biggest complaints about ForeUI is with loops. All I ever want to do is to perform a loop – but despite there being a “loop” flow control option it does not exist. Instead, the ForeUI “loop multiple times” or “loop while condition…” flow control structures force a series of actions to occur on a timer. I don’t want a timer, I want a loop!
Here is an example where I might want to rotate between 3 images
Display Image 1
Display Image 2
Display Image 3
So that, while running, a user only sees a rotation of Image 1, Image 2, Image 3, Image 1, Image 2, Image 3, etc…
I could hack this example together by making the loop “Interval” 1500ms. But this is a terrible way to NEED to setup a loop. For one thing, I may later add a forth image or some other action to my loop. Every time I add an action I would have to remember to adjust the loop time and recalculate. For another thing, sometimes it is unclear how long a loop may take to execute. Especially once you have 10-20 actions being performed, or use odd delay timings or different delay lengths for each image (220ms + 175ms + 350ms + 735ms + etc = ?)
As a result, many times I have to manually tweak my loop interval multiple times during development or simply cannot accomplish what I need to. Often I want a loop to do 1 then 2 then 3 then repeat only to find out that my interval timer is too short and after a few itterations I have 4 simultaneous loops working against each other causing a stutter or I must use a REALLY long loop intervale to ensure against concurrent loops but at the sacrifice of a long delay at the end of my loop before restarting.
I had hoped “interval = 0″ would be a special value to work as I wanted but actually it just seems to cause true infinite simultaneous loops and crashes my browser. All I want / need is a loop that only repeats after the last item within the loop is completed. No delay or timer based loops.
P.S. Beta v4 is really buggy but as long as you know the tricks to work around the limitations it is otherwise functional.
I think you misunderstood the meaning of “interval” for the loop in ForeUI. The interval doesn’t mean how long the content in the loop will last, instead it means the time to wait before entering the next cycle.
[Cycle 1]->wait interval->[Cycle 2]->wait interval->[Cycle 3]->……
So you really don’t need to calculate the timing, if you don’t need any additional wait between the cycles, you can set interval to 1 millisecond. You are right about that, in V4.0 the interval with zero value is very special, it is reserved for special purpose, in which case you should not put long task into the loop, or it will really block the web browser. We will put more details about it in the document for V4.0.
I made an example for you. It is quite similar with the example you mentioned. In stead of showing/hiding images, I change text of TextBox element. You will see its text keep rotating between 1, 2 and 3:
Please notice the interval is 1ms here, means (almost) no additional waiting between cycles.
You can download the example plot here: http://www.foreui.com/misc/tmp/loop_test.4ui
Thanks for the quick reply – but I’m sorry to say that your post is not accurate. In every Plot I have made the interval causes the loop to RESTART regardless of the status of the loop contents. If the loops worked as you have said, where the interval is actually the delay between iterations, then that would be very ideal. Unfortunately, for all of my attempts, the interval is a delay before another instance of the loop occurs (or restarts?).
I can not share my real plots as they contain private information, and are complex but I just created a simple example.
There are 3 elements: 2 check boxes, and 1 imagebox. I also have 2 images (img0, img1). I want the image box to show the image associated with a marked checkbox. If both are marked then the image will bounce between both images every second. If I set the interval to 1000ms the function works acceptably (although based on timing there could be a 1 second delay before the first selection is registered). However, if I set the interval to a low value as you suggest, such as 10ms, then only the first selected image is displayed and the loop repeats every 10 ms,……. despite having a 500ms delay built into my loop.
I will attempt to upload a screenshot.
As I showed you in my previous example, if there is just loop and delay between steps, it works well.
You may not imagine that, it was the conditional branching in the loop caused the problem in your example. It is hard to explain it very clearly because it involves too many technical details. The summary is that, if we put conditional branch into the loop, the cycle in the loop will not wait until all steps get executed.
In your example, if you remove the conditional branching inside the loop, you will see it works well.
I prefer to take this as a known limitation. At the time being we don’t see a good way to fix this. However, there is workaround for this, which is to avoid putting the conditional checking inside the loop. I create an example that works as you expected, and you can download it here: http://www.foreui.com/misc/tmp/rotate_images.4ui
The idea is to avoid placing conditional branching in the loop, and introduce a proper way to stop the loop. I hope that’s helpful for you.
I really loved it here but are there any recent updates? Thanks https://paintersamarillotexas.com
This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. permanent hair removal
I really welcome this great post that you have obliged us. I ensure this would be significant for by far most of the overall public.
Is there some way to do the same thing from an action? When I try to use a backslash-n in the “Set Cell Value” action. Bed Bug Control
Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can’t wait to read lots of your posts.
I have the same problem, took me time to read all the comments, but I really enjoyed the comments. It proved to be very helpful to me. Thanks, Vivi from all of us at drywall installer company
I had same question last week!)
I have learned a few just right stuff here. Definitely value bookmarking for revisiting. You also visit my Roofing website if you are looking for reliable roofing services. Thanks in advance
I had the same problem; it took me a while to read all of the comments, but I thoroughly liked them. It was quite beneficial to me. Thanks, Vivi from the Columbus Drywall Pros
The contributions of other members are very helpful. http://www.drywallamarillo.com appreciates your initiative in sharing your insights.
I’m appreciative of this. I’m grateful that you did this.
snake game is so fun. In this game, you will control a snake with the arrow keys to eat the fruit and avoid hitting the wall or the snake itself.
The interval doesn’t mean how long the content in the loop will last, instead it means the time to wait before entering the next cycle.
Overall, using loops effectively takes practice and experience. I encourage you to read and study the relevant documentation for the programming language you’re using, and to try out some examples to get a better understanding of how loops work. You can also consult with a more experienced programmer to guide you and answer any questions you may have.
Jan | Business financing