From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Runing another idea inside a while loop

Solved!
Go to solution

I want a while loop to run inside another while loop, The second while loop should work indefinetely while go is pressed, if go is unpressed it stops but if go is pressed again it runs again...

What am I doing wrong?

0 Kudos
Message 1 of 17
(4,304 Views)

Looking at the code nothing looks 'wrong'. You've got one while loop running inside another exactly as you've described. Can you describe what you expect to happen?




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 2 of 17
(4,288 Views)

Hi,

 

I think, you would disable the code inside of second while loop if do == false. But it is a "post testing" (do) while loop, so your code will be executed firstly, after LV checks your condition. So you have to wrap into a case structure your while loop (pre testing), and your while loop will be executed only if do == true.

 

Balint

Message 3 of 17
(4,276 Views)

I want the while loop with thw button GO to work when the GO button is green, and that it can be turn on and off again without restarting the whole program

The idea is not hard, I just don't know how to do it

0 Kudos
Message 4 of 17
(4,260 Views)

It is all about my "Go" button....

0 Kudos
Message 5 of 17
(4,239 Views)

I don't see "GO" button, only "DO".

0 Kudos
Message 6 of 17
(4,234 Views)

Yes that one

0 Kudos
Message 7 of 17
(4,232 Views)
Solution
Accepted by topic author LP_C

Instead of a while loop inside of another loop, just use a case structure.  Embedded loops are typically a poor solution.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 17
(4,219 Views)

What is the significance to adding the 3E-14 to the loop counter?  After the first iteration of the outer loop, you will essentially be adding 0 to the loop count as the DBL precision variable will lose that resolution.  Are you expecting that?

Loop 0: Sum = 3E-14

Loop 1: Sum = 1

Loop 2: Sum = 2

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 9 of 17
(4,191 Views)

@Minions wrote:

What is the significance to adding the 3E-14 to the loop counter?  After the first iteration of the outer loop, you will essentially be adding 0 to the loop count as the DBL precision variable will lose that resolution.  Are you expecting that?

Loop 0: Sum = 3E-14

Loop 1: Sum = 1

Loop 2: Sum = 2


Maybe it is an attempt at mitigating some floating point precision issues?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 17
(4,183 Views)