LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

formula node Error

this is a basic question, I have a formula node in a for loop, and I am getting this errors:Error on line 4 is marked by a '#' character: "...; P2>=P1; X=P2; else# X=0; "
I dont know what it means, i have posted my code from my progra below:
 
if (P1>1);
    P2>=P1;
X=P2;
else X=0;
 
am I missing a bracket or something???? Im not sure how to write the formulas in LabVIEW, but basically thats how I would write it in C++.
I have two for loops in my program. Im putting this formula node in the inner for loop. I want to say that if P1 is greater than 1, and then check to see if P2 i greater then or equal to P1, if so then X is given the value P2, if not I want it to exit the loop and iterate the next number in the inner loop. 
0 Kudos
Message 1 of 5
(2,925 Views)

I think that your formula is very close.  If I got your explanation correct, this is the formula to use:

if (P1>1) {
if (P2>=P1) {
X=P2;
}
else
X=0;
}

You need to have the to ifs be explicit or need to

Or you could go the old fashioned route and do it this way:

P1>1 ? ((P2>=P1) ? (X=P2): (X=0)): (0);

But I would stick with the C implementation if you are comfortable with it Smiley Wink

Hope that this helps,

Bob

0 Kudos
Message 2 of 5
(2,912 Views)
it works now, thanks for the fast reply
0 Kudos
Message 3 of 5
(2,910 Views)
I have a for loop if I connect an indicator to the N (number of iterations ) to it, what does that do?
 
say i run my program and it gives me data for 5 values does the loop iterate 5 times of does it iterate the values stored in the indicator????
0 Kudos
Message 4 of 5
(2,908 Views)

Depending on how the FOR loop is set up (what is being passed in, what it is doing) the # connected to the N terminal tells it how many times to loop. If an array is connected to the input side (left) of the loop and it is set to autoindex (signified by a little square connector with white space in the center), it will loop either the number connect to the N terminal -OR- the number of elements in the, which ever is smaller.

 

P.M.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 5
(2,903 Views)