LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incrementing a variable based on the condition

Solved!
Go to solution

Hi,

 

 Yes, you are right. My mistake, sorry. For example, if I want to exit a loop:

int counter; //it is my global value

for(int i = 0; i < dataValue.size; i++)

{  

   if(dataValue == randomValue)

   {

     counter++;

     if(counter  == 2)

     {

        break;

     }

 

   }else{

    //do nothing 

}

 

 So in that case, my loop will not be executed if my counter reaches 2. That's exactly what I want to implement in Labview. So can I create another comparison then connect it stop button ?

 

Thanks for the help

 Screen Shot 2018-04-18 at 2.10.06 PM.png

0 Kudos
Message 11 of 14
(721 Views)

Hi,

 

 Thanks for the answer. Yes, it worked. I would like to iterate my for loop and exit if the condition met. For example, if I want to exit a loop:

int counter; //it is my global value

for(int i = 0; i < dataValue.size; i++)

{  

   if(dataValue == randomValue)

   {

     counter++;

     if(counter  == 2)

     {

        break;

     }

 

   }else{

    //do nothing 

}

 

 So in that case, my loop will not be executed if my counter reaches 2. That's exactly what I want to implement in Labview. So can I create another comparison then connect it stop button ?

 

Thanks for the help

 

0 Kudos
Message 12 of 14
(717 Views)

Yes. Do a comparison with your threshold value, then wire the output to an OR node. The other operator of the OR must be the Stop button.

Wire the output of the OR to the conditional terminal.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 13 of 14
(716 Views)
Solution
Accepted by topic author aybarskizilay

@aybarskizilay wrote:

 So in that case, my loop will not be executed if my counter reaches 2. That's exactly what I want to implement in LabVIEW. So can I create another comparison then connect it stop button ?


Learn Boolean Logic.


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 14 of 14
(702 Views)