LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

formula node: Else if

 

 

I want to use a formula node to make my code smaller.

I'm comparing a sensor value and depending on the value i have 3 options.

At the moment i get the error that labview thinks my 'Else if ' is a variabel instead of a command.

am i doing something wrong? another option is to use a Case-structure but this code is allready in a case so i don't know if this could give trouble.

 

thanks,

 

Lars

 

0 Kudos
Message 1 of 7
(2,058 Views)

Hi Lars,

 

what about 2 3 statements:

Set output values to default values (aka last ELSE part)
IF x < y THEN set values (aka first IF part)
IF x > y THEN set other values (aka second IF part)

 As this example:

check.png

 

Why don't you use a case structure?

 And keep in mind the limited resolution of floats when comparing them…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 2 of 7
(2,048 Views)

Still Overkill with the CPU overhead why not: (VI attached in 2010 for compatility)threshold.png

 

Bah - you edited after just before I posted Gerd - there was no Pic there before!

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 3 of 7
(2,039 Views)

Or without any case structure (and without non-typedef'd enums 😉 😞

check.png

You just have to put the correct numbers into the array constant…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 4 of 7
(2,033 Views)

Elegant Gerd, Scalable (and I would have typdef'd If I was keeping myself) but much less readable and unable to add e.g. a String to the same array - then the BD starts to get messy again.

Waiting for Christian to post with 1 compare function using a complex number that makes even your look big and a Rube!Smiley Very Happy

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 5 of 7
(2,020 Views)

Hi James,

 

when you want to mix datatypes you go with an 1D array of cluster and unbundle instead of the 2nd IndexArray…

 


Waiting for Christian to post with 1 compare function using a complex number that makes even your look big and a Rube


 

My own idea:

check.png

Just one comparison… 😄

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 6 of 7
(2,017 Views)

good point

Yesterday I needed my eyes tested for failing to see a comma,

now I think I need sleep for failing to think of the ovbious!

 

(Still waiting for Christian's wizardry though. - I don't think your is a Rube but he has a horrible habit of making thing that look simple like that even more simple!)

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 7 of 7
(2,013 Views)