03-03-2022 03:06 AM - edited 03-03-2022 04:01 AM
Hi,
I try to use a progress bar in a bigger code.
It should also stop if the user stops the code.
I attached a the code I created. The only difference here is that the while loop cancels the other loop. Thats not the case in the bigger code, there the while loop just listens. I think the code works correctly, but can you help me where it code be coded in a better way? It looks really messy for me.
greetings
melody
edit: somehow i can not get the timing correctly
03-03-2022 09:35 AM - edited 03-03-2022 09:37 AM
It's not bad at all.
You can make it better though by simply straightening some wires, making sure they are not going from right to left:
Before:
After:
The error coming out of obtain notifier doesn't really do anything. If there is an error obtaining the notifier, the reference is invalid and the Waits will throw an error anyways.
03-03-2022 09:51 AM
wiebe@CARYA wrote:
It's not bad at all.
You can make it better though by simply straightening some wires, making sure they are not going from right to left:
Before:
After:
The error coming out of obtain notifier doesn't really do anything. If there is an error obtaining the notifier, the reference is invalid and the Waits will throw an error anyways.
I agree that it stands quite well on its own. The main thing is that you can tell that a lot of thought was put into making it readable. It's mostly about personal preferences here.
FYI, code neatness isn't just about being anal; it is essential, especially when creating complicated code. (It really shouldn't be too complex, but that's a discussion for another time.) The reason for this is essentially the same as the reasons for using regular indents in text coding: It doesn't matter to the compiler that you have random indents, but if someone came looking for you because he wanted to strangle you for using random indents, I'd point to your desk and go to lunch so I could have some plausible deniability. Keep the wires as straight as you can, don't have them running behind stuff, don't have objects hiding behind others, stuff like that, and it will be easy to read, easy to maintain, and easy to troubleshoot.
03-03-2022 10:34 AM - edited 03-03-2022 10:40 AM
Why. So. Complicated???
Maybe all you need is the following (It even updates the elapsed time with each iteration):
03-03-2022 11:15 AM
I would also suggest to make the progress bar invariant to N so it goes to 100% over all outer iterations no matter what's wired to N. One possibility:
03-03-2022 11:52 AM - edited 03-03-2022 11:54 AM
@altenbach wrote:
I would also suggest to make the progress bar invariant to N so it goes to 100% over all outer iterations no matter what's wired to N. One possibility:
I just use a Property Node to set the Scale->Range->Maximum to be N-1. I can then just wire the FOR Loop's iteration terminal directly to the indicator.

03-03-2022 12:26 PM
@crossrulz wrote:
@altenbach wrote:
I would also suggest to make the progress bar invariant to N so it goes to 100% over all outer iterations no matter what's wired to N. One possibility:
I just use a Property Node to set the Scale->Range->Maximum to be N-1. I can then just wire the FOR Loop's iteration terminal directly to the indicator.
In most cases, I show the digital display too, so this won't work 😄
03-04-2022 01:55 AM
thanks for your replies, I will go through them today.
The first version was just a for loop. But when I had testruns over a few days (like 30) the progressbar would update every 30 days/100 and in that case the stop button lost its purpose. That is why I did create an inner loop to get more updates of the status of the stop button
03-04-2022 02:21 AM
As I said, you could just place the stop button inside the inner loop. In a pinch, even a local variable might work.
If your problem are in different code, maybe you should show us that. It is possible that you have some dataflow problems. How longs is one iteration?
03-04-2022 08:06 AM
One iteration depends on the time I run the program. I had N as 100 maximum in the for loop.
Until know I haven't used property nodes. But that solution works perfect ... took me some time to find our that I have to change it to accept input parameters 😄