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.
06-14-2016 02:56 PM
I see some very old posts that function declaration is not supported in formula nodes. Is this still the case? Are there any work-arounds besides a sub-VI?
Thanks,
Justin
06-14-2016 02:59 PM - edited 06-14-2016 02:59 PM
Hi Justin,
Are there any work-arounds besides a sub-VI?
Why do you call the creation of LabVIEW subVIs a "workaround"? 😉
What exactly do you want to achieve with LabVIEW? Why do you think you need a formula node to reach this goal?
06-14-2016 04:45 PM
GerdW,
Thanks for the quick reply. I think I used the term "work-around" because it was used in an earlier post, but this is not really the case since the function declaration and the sub-VI are 2 different things (at least in my mind).
I routinely use formula nodes when I'm doing a whole bunch of algebra. I find it cleaner and easier to interpret and comment than wiring up the math. I also routinely drop them into a sub-VI to keep the parent block diagram neat. I would never look at this as an analog for a function declaration within the formula node full of algebra though. But I do see how it can be interpreted that way.
It would be nice to be able to declare a function inside the formula node for the same reason it's nice to be able to do it in C code. It just makes doing some math more efficient. It's really no different than the efficacy of using the built-in functions when appropriate. For example if I want to pick the maximum between 2 numbers I'd just us the max(x,y) function instead of writing my own conditional everytime.
Anyways, I can do the tedious, repetitive math just fine without the ability to declare a function in the formula node, but like I said, it would be nice if I could.
Thanks,
Justin
06-14-2016 05:05 PM
Think of a VI as declaring a C function. Each VI is assigned to do a specific task and when combined with other "functions", they accomplish your end goal. Don't try to throw all of the code into one VI because you are right, it would be difficult to interpret what is happening. But when split up and properly documented, the code should be easy to understand.
06-14-2016 06:19 PM
@jbarber wrote:For example if I want to pick the maximum between 2 numbers I'd just us the max(x,y) function instead of writing my own conditional everytime.
Here's Max and Min of two numbers:
Bob Schor
06-14-2016 07:01 PM