From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-09-2014 06:10 AM
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
05-09-2014 06:23 AM - edited 05-09-2014 06:27 AM
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:
Why don't you use a case structure?
And keep in mind the limited resolution of floats when comparing them…
05-09-2014 06:27 AM - edited 05-09-2014 06:29 AM
Still Overkill with the CPU overhead why not: (VI attached in 2010 for compatility)
Bah - you edited after just before I posted Gerd - there was no Pic there before!
James
05-09-2014 06:32 AM - edited 05-09-2014 06:33 AM
05-09-2014 06:51 AM
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!
James
05-09-2014 06:54 AM - edited 05-09-2014 06:58 AM
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:
Just one comparison… 😄
05-09-2014 06:58 AM
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