LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

formula node, condition

I want to use conditional expressions such as
if () then
statement
else
.
.
.
end if

in the formula node, but there were error messages "unassigned output".

I followed Ankita's suggestion to use
if (x<5)
{
y=4;
z=8;
}
else
{
y=8;
z=4;
}
but there were same error messages(I tried "end if;" also.).

Thanks.
0 Kudos
Message 1 of 6
(3,388 Views)
Which version of LabVIEW are you using? Any chance it is earlier than 6.0?

If so, then Ankita's suggestions probably won't work, because there were major changes in Formula Node behavior. I recall that every variable introduced in pre-6.0 formula nodes had to be explicitly added as either an input terminal or an output terminal on the formula node. Furthermore, those older formula nodes used a different style for conditional syntax. It's all documented in the manuals or help documentation that shipped with your LabVIEW version, whatever that may be.

More to the point, I suggest that you abandon the formula node for simple conditionals like this and just use a case statement. You can wire your x variable into a less-than node, then wire the output of that into a case statement selector. You can very often avoid formula nodes by using case statements or even the "Select" node on the Comparison palette.

My two cents,
John
Message 2 of 6
(3,379 Views)

Here is an example of an if statement in labview

if (y==x && a[2][3]<a[0][1]) {
     int32 temp;
     temp = a[2][3];
     a[2][3] = y;
     y=temp;
     }
else
     x=y;

 

 

Another simple if statement

if (x>.004 && x<=.008)
y=.000267;
else if (x > .008 && x<= .012)
y = .000299;
else if (x > .012 && x<= .016)
y = .000322;
else if (x > .016 && x<= .020)
y = .000355 ;
else
y = .000400;

Message 3 of 6
(3,016 Views)

Hi vic,

 

congratulations to your first post in this forum!

 

Did you notice you're answering to an 9 years old thread where the OP also left the forum 9 years ago?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(3,004 Views)

The thread still comes up in a search, the example will work in labview 2013..so your point is?

0 Kudos
Message 5 of 6
(2,969 Views)

Hi vic,

 

my point is to let those old threads rest in peace.

 

Yes, you will find all those old threads as NI keeps them for us.

Yes, your example will work.

Yes, that example should be coded in pure G…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(2,966 Views)