LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to repeat the for loop desired times

Solved!
Go to solution

i am new to labview.I want to run the loop continuously. and i used the for loop with auto indexing input.it should run with respect to the  array input.and it should ask for repeat after giving repeat it should run again.and when giving stop button it should stop.i have attached the image.how i have to include the repeat botton..

1

2

3

if repeat is given then it should run like again

1

2

3

stop.it should come out of program 

 

0 Kudos
Message 1 of 8
(601 Views)

Hi gokila,

 


@gokila11 wrote:

it should run with respect to the  array input.and it should ask for repeat after giving repeat it should run again.and when giving stop button it should stop.i have attached the image.how i have to include the repeat botton..

1

2

3

if repeat is given then it should run like again

1

2

3

stop.it should come out of program 


Sounds like you want to run a FOR loop within a WHILE loop: the FOR loop always autoindexes all aray elements (1…3), then the user can decide for repeat/stop, then the (outer) WHILE loop either iterates again or stops…

On the other hand this also can be a great start to learn about statemachines!

 


@gokila11 wrote:

i have attached the image.


No, there are no attachments…

 


@gokila11 wrote:

i am new to labview.


Did you notice those "Training resources" offered at the top of the LabVIEW board?

 

Btw. it helps when you obey usual grammar and spelling, like using proper capitalization and leaving a space after the end of a sentence. Also LabVIEW uses a special kind of spelling…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 8
(594 Views)

Yes,I want to run the for loop within the while loop. Array(1 2 3) input  is given as the input to the for loop.As I am using the while loop it runs continuously like 1 2 3 1 2 3 1 2 3 .But what I need is like ,after 1 2 3 then it should ask for repeat or stop accordingly it should act.So here what logic I have to use.Screenshot (61).png 

0 Kudos
Message 3 of 8
(578 Views)
Solution
Accepted by topic author gokila11

Hi gokila,

 


@gokila11 wrote:

after 1 2 3 then it should ask for repeat or stop accordingly it should act.


Then you need to implement that question (aka dialog) so the user can choose:

 

Btw. you should get into the habit of cleaning up code immediately! It helps to create readable code…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 4 of 8
(574 Views)

Hi,

I am using for loop within the while loop and the input of for loop is array which is autoindexed. Here I have two button(boolean control)for continue and stop.If continue is pressed , for loop should execute again and if stop is given then the program should be stopped.Help me to complete this.

0 Kudos
Message 5 of 8
(583 Views)

It's hard to help without a vi so that we can see what you have. From your description I would make a state machine. Have you reviewed the training materials at the top of this page?

0 Kudos
Message 6 of 8
(542 Views)

You might be better off using a Two button dialog as the input for the while loop if it going to halt after each iteration of the FOR loop.  Make one button 'Continue' and the other 'Stop' for the Two button dialog.  It should appear after the completion of the FOR loop.

 

The other option would be to use the Boolean Radio Button.

 

My $0.02

 

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
Message 7 of 8
(538 Views)

Hi sanjay,

 


@sanjay92 wrote:

Help me to complete this.


Why don't you talk with your classmate gokila when you get the very same task as homework? Atleast (s)he was quicker in providing an approach with an image of code - more than you did to solve the homework…

 

(I merged your threads!)

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 8 of 8
(527 Views)