キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

stop for loop

Hi,
I'm using for loop for let's say i=40
can i stop the loop in the middle (when i=20) and contino the program from there?
Regards,
Etay
0 件の賞賛
メッセージ1/8
4,588件の閲覧回数

Its not possible to do that in LabVIEW

The FOR loop has to finish its set number of iterations before stopping

 

メッセージ2/8
4,569件の閲覧回数
You must use a while loop if the loop must be stopped before its set number of iterations !
0 件の賞賛
メッセージ3/8
4,561件の閲覧回数
For now that is.  to answer your question, you can put the 'meat' of your code within a case structure, and 'skip' it if you have an undesireable condition.  Or you can create a while loop with multiple exit scenerios including your undesireable condition(s) or completion of processing your data structures.  The choice is yours. 

Paul
0 件の賞賛
メッセージ4/8
4,552件の閲覧回数
 
In this case the loop can be stopped before the loop count
If the loop count is 20 and the array size is 10 then the loop will iterate for 10 times only
If the loop count is 10 and the array size is 20 then also the loop will iterate for 10 times only
So which ever is less the loop will iterate that many times
0 件の賞賛
メッセージ5/8
4,550件の閲覧回数

Hi Kumar,

Can you attach the screenshot once again ?

- Partha ( CLD until Oct 2027 🙂 )
0 件の賞賛
メッセージ6/8
4,544件の閲覧回数
 
On Parthabe's request reattaching the image
In this case the loop can be stopped before the loop count
If the loop count is 20 and the array size is 10 then the loop will iterate for 10 times only
If the loop count is 10 and the array size is 20 then also the loop will iterate for 10 times only
So which ever is less the loop will iterate that many times
Still not able to catch the image.???????? i can mail you if you could post your mail id
0 件の賞賛
メッセージ7/8
4,539件の閲覧回数

You can also program the logic into it. I've used this a few times. Just put everything in the loop inside a case structure, then you can do some boolean operation that you want to use to stop the loop, wire this to a shift register and use it on the next iteration. In the true case, just wire everything through so nothing happens once the condition is met. The loop is still running, but it isn't doing anything and will finish very quickly.

I also added a shift register for the iterator in this example so you could obtain it after the "break" condition occurred.

Message Edited by Marc A on 06-13-2007 09:02 AM

0 件の賞賛
メッセージ8/8
4,521件の閲覧回数