cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping a For Loop

Mike227
Member

Stopping a For Loop

How do I stop a for loop with a stop button? I have 2 case structures and 2 while loops inside my for loop.

 

 

10 REPLIES 10
Trusted Enthusiast

Re: Stopping a For Loop


@Mike227 wrote:

How do I stop a for loop with a stop button? I have 2 case structures and 2 while loops inside my for loop.

 

 



Change the FOR loop to a WHILE loop.

 

 

odessy27
Member

Re: Stopping a For Loop

select and right click on the for loop, and check conditional terminal.



------------------------------------------------------------------------------------------------------
Kudos are (always) welcome for the good post. :-)
Mike227
Member

Re: Stopping a For Loop

Message contains an attachment

Attached is my VI.

 

I think I need the FOR loop because I use an iteration control. (control off of the N symbol) And I have an auto indexing array feeding in.

Trusted Enthusiast

Re: Stopping a For Loop


@Mike227 wrote:

Attached is my VI.

 

I think I need the FOR loop because I use an iteration control. (control off of the N symbol) And I have an auto indexing array feeding in.



If you stop the FOR loop, then not all the elements array are going to be processed. If that is fine with you, then do it.

 

 

Mike227
Member

Re: Stopping a For Loop

yea, but how would I do that? Ive tried the conditional terminal for the FOR loop, and it then won't write my text to the file.

crossrulz
Knight of NI

Re: Stopping a For Loop

Is there an error being generated?  An error should be the only thing keeping the file from writing.



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
Mike227
Member

Re: Stopping a For Loop

There are no errors that I can find. Is there a way to manually find an error?

altenbach
Knight of NI

Re: Stopping a For Loop


Mike227 wrote:

I think I need the FOR loop because I use an iteration control. (control off of the N symbol) And I have an auto indexing array feeding in.


Your array is empty, thus the for loop will iterate zero times, no matter how big the number wired to N is.

I would recommmend to exclusively stick to "build path", "strip path" primitives. Dont manipulate entire paths as strings.

Should "test programs" be a folder or part of the filename? Does the folder exist?

If you want to stop at any time, the stop button belongs into the innermost loop.

altenbach
Knight of NI

Re: Stopping a For Loop

Message contains an image Message contains an attachment

Also note that you use an obsolete file open function. But since you wired the start path, it seems that "test programs" is actually a folder name and not part of the desired file name.

 

Anyway, your upper left code could look as follows.

 

 

 

Also note that making a string diagram constant bold will not make the text in the resulting file bold. Smiley Very Happy