Allow a vi node to accept any input type
labview, templates, variant
Solution
Some additional options:
- There should be some shipping VIs which tell you what the type of the data in the variant is. This should simplify the previous suggestion, because you simply start with a case structure and cast to one type inside each case. The VIs should be in vi.lib, I believe in a folder called VariantDataType or possibly in the Utility folder.
- Create a polymorphic VI - it's basically a group of VIs (one for each data type) which are connected using the poly VI. Once you drop it in the diagram, LV automatically selects the correct VI based on the the type of wire you use. The big advantage with this is that the code is simple and clear.
Problem
I want to create a VI that will accept an Integer,float,bool,string, or enum as an input node (but only a single node), then inside my VI detect the input type so that I can use the data in different ways. Can anyone point me in the right direction with this, I'm thinking about variants but not really sure how to go about it. I want my VI to basically work in the same way that a C++ function using a template type, or an overloaded function would work. Thanks, Eamonn