ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to exit a while loop ?

Solved!
Go to solution

How can I exit a while loop ?

I'm new to Labview and I've tried to do my first Labview programm.

I've taken an old example, a sieve for prime numbers. The old Erasthotenes sieve.

Similar to that (Visual Basic Example):

 

While (l <= k) and Teiler <= Math.Sqrt(i)

       Teiler = TeilerArray(l)

 

0 Kudos
Message 1 of 13
(7,106 Views)

How can I exit a while loop ?

I'm new to Labview and I've tried to do my first Labview programm.

I've taken an old example, a sieve for prime numbers. The old Erasthotenes sieve.

Similar to that (Visual Basic Example):

 

While (l <= k) And Teiler <= Math.Sqrt(i)

       Teiler = TeilerArray(l)
       If i Mod Teiler = 0 Then
            IstPrim = False
            Exit While
       End If
       l = l + 1
End While

So, how can I model that "Exit While" ?

0 Kudos
Message 2 of 13
(7,098 Views)
Use the conditional terminal of the while loop to stop it, based on a logical conditional check for your code.
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 3 of 13
(7,094 Views)

Where do I find this "conditional terminal" and what is it called in German ?

Is it "Haltepunkt" in the context menu of the while loop ?

How do I use the "conditional teminal" ?

I use the german version.

0 Kudos
Message 4 of 13
(7,073 Views)

Pl see the attached snapshot.

 

Sorry, I dont know German.

- Partha ( CLD until Oct 2027 🙂 )
Message 5 of 13
(7,070 Views)

This is not an exit statement.

See below.

 

http://zone.ni.com/devzone/cda/tut/p/id/6285

 

As it seems to be only the for loop supports an exit statement.

"Conditional terminal" in the context menu.

0 Kudos
Message 6 of 13
(7,065 Views)

Hi Hans,

it is an exit statement. If you connect the correct value to it, then the loop stops.

You can use a case structure to don't run other code if a special "stop event" occur.

 

Mike

0 Kudos
Message 7 of 13
(7,054 Views)
Solution
Accepted by topic author HansWerner

Hans,

 

What you have linked is for the FOR loop, what I had attached is for the WHILE loop. Smiley Wink

 

Only the type of the loop is different, but the concept or logic is the same for both. Smiley Happy

- Partha ( CLD until Oct 2027 🙂 )
Message 8 of 13
(7,046 Views)

Ok, I will try this.

I've thought that this is only a button to stop the loop.

0 Kudos
Message 9 of 13
(7,015 Views)

HansWerner wrote:

Ok, I will try this.

I've thought that this is only a button to stop the loop.


 

Yes you are correct, what is the differene between 'exit' and 'stop'

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 10 of 13
(6,996 Views)