05-30-1999 06:13 AM
05-30-1999 10:02 AM
06-19-2015 03:14 PM
Amazing how 16 years later, that's still pretty much the only supported approach...
06-22-2015 08:33 AM - edited 06-22-2015 08:34 AM
@X. wrote:
Amazing how 16 years later, that's still pretty much the only supported approach...
That's not true at all. LabVIEW is a striclty typed programming language so having flexibility in input is going to be a problem. Of course this gives the benefit of knowing you'll never have any compile type syntax errors.
So you can flatten to a string, or you can convert to a raw array of bytes, or you can use a variant. All of these options will allow you have an input that accepts multiple data types but they all have the same problem, which is that you need to code each data type you actually want by converting it to the strictly typed data you want so you can use it.
This is why most people when they need this look for polymorphic VIs which allow them to have a VI for each type, and then have the VI automatically select the type based on the wired input. This works well if you have say 10 or less data types to support. It can work for 60+ but managing those instances can be a pain without proper scripting.
But the magic bullet in my opinion is XNodes. They are nodes on the block diagram, that create code, as you interact with them. They have easy type adaption for inputs and outputs, and can allow for things like resizing, adding inputs or outputs. The regular expression function is an XNode which is just a collection of VIs in a specific library, which says when to run each VI as you interact with it.
XNodes development is not something NI wants non-NI developers doing, but some amazing things can be done with XNodes where the code to interact with something is written, as you wire it up. It has the flexibility of variants, but the strict data typing of polymorphic VIs.
Remember XNodes are very experimental and NI will not support code written with them, that being said XNodes are made by NI and shipped with LabVIEW, so they are considered stable in some cases. They are also a lot of fun to play with and make, here are some of my favorite examples.
https://lavag.org/files/file/250-circular-buffer/
https://lavag.org/files/file/260-find-references-xnode/
https://lavag.org/files/file/248-variant-repository/
https://lavag.org/files/file/169-openg-array-xnodes/
http://forums.ni.com/t5/LabVIEW/Truth-Table-Node/td-p/1293680
https://decibel.ni.com/content/docs/DOC-13859
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-22-2015 11:41 AM
XNode is precisely what I was referring to and it is still not officially supported. QED.
06-22-2015 11:59 AM
What is wrong with using Variants? There are functions that will tell you the type of the Variant, allowing you to extract the data in the proper format (though admittedly this can get recursively messy if the Variant is, say, a Cluster or Array). In other cases, you can use Polymorphic VIs. I think it depends critically on What Needs to be Done ...
BS
06-22-2015 11:59 AM - edited 06-22-2015 12:04 PM
I've heard a couple NI people state XNodes will never see an official release, and I've heard some say that a release could happen someday and NI is working on it.
They are so damn powerful, I don't know how NI couldn't be at least considering it. Only time will tell.
EDIT: @Bob there is still lots of things XNodes can do in terms of terminal adaption that a Variant can't. You can have an XNode terminal be adaptive and be any type, that is allowed up stream. So internally if you use a Search 1D array function and that XNode terminal is adaptive, then that terminal accepts a 1D array of any type and is broken otherwise. To handle this there is one block diagram constant that needs to be set to True. Much easier than using a Variant, and reading the type, and converting. The XNode is also clear what types it accepts. If the wire is broken it doesn't accept it. With the variant you'll get a run time error which can be harder to debug and understand.
I think I really like the reusability of XNodes. Spend a little time up front and it can be used everywhere. Polymorphic VIs are a bit of a pain, spend lots of time up front and it can be used in a few more cases.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-22-2015 01:34 PM
BTW, my comment was not supposed to trigger any response.
I just had some fun looking at the forum's post in reverse chronological order.
There are some nostalgic stuff there...
06-22-2015 04:27 PM
@X. wrote:
BTW, my comment was not supposed to trigger any response.
I just had some fun looking at the forum's post in reverse chronological order.
There are some nostalgic stuff there...
Fair enough, but looking back you do get to see how much, and how little has changed. Also I think 16 years might be a new record, but it was intended so I'm not counting it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord