07-06-2005 09:22 AM
07-06-2005 09:30 AM
Here is the syntax that I found in the help on if statements. Try looking at the help. Sorry i could not help more
if-statement:
if ( assignment ) statement
if-else-statement:
if-statement else statement
07-06-2005 09:33 AM
07-06-2005 09:40 AM
07-06-2005 09:42 AM
@Novatron wrote:
I thought that code in those nodes was based on C... If my memory serves me correctly, an else if statement is C is "elsif" not "else if"
07-06-2005 09:46 AM
07-06-2005 11:13 AM
07-06-2005 11:41 AM
That answer was as helpful as when people ask for help with windows and the reply is use Linux. Sorry if I sounded arrogant.
@tbob wrote:
Forgive me for sounding arrogant or foolish, but don't we use Labview to get away from text coding? Why even bother with if-else statements in a formula node? Why not do the whole construct in Labview graphically? I have never used a formula node and I don't expect to ever use one. All formulas can be created with Labview numerical functions. I guess I could see constructing a complex formula of math functions (X=2a^2+4b+c-d) using a formula node, but why would anyone want to use a formula node to perform text based coding like if-else and such? Use Labview graphics and your troubles are over.
07-06-2005 12:07 PM
07-06-2005 12:28 PM
I was just wondering why anyone would use a formula node for if-else. But if that is your preference, so be it. I have tried this bit of code in a formula node and it works fine: (a is the input, x is the output)
if(a==0)
{
x=1;
y=11;
}
else if(a==1)
{
x=2;
y=12;
}
else if(a==2)
{
x=3;
y=13;
}
else
{
x=-1;
y=-1;
}
I also tried an exact copy of your construct:
if(a==0) {
x=1;
y=11;
} else {if(a==1) {
x=2;
y=12;
} else {
x=-1;
y=-1;
}
}
It worked fine.