There are two ways that you can create a VI with a terminal that
mimics the behaviour of the "anything" type.  The first is to create a
Polymorphic VI.  This allows you to know exactly what kind of data was
wired into the VI.  Of course, the drawback is that you must create a
new version of your VI for each data type that you wish to support.
This is difficult to do if you want to allow for complex types.  If
you want to allow for complex types, or you don't know yet what types
can be wired in, this will prove impossible.

The other way is to create a VI with a variant control that will be
your polymorphic terminal.  On the block diagram of your VI, you will
want to drop the "Variant To Flattened String" primitive
(Functions->Advanced->Data Manipulation->Variant).  This primitive
will provide you with both a flattened string of data (the "data
string" terminal) and a type descriptor (the "type string" terminal).
Use the type descriptor to determine what kind of data you have.  If
you follow the help links on the primitive (click on "Click here for
more help" in the context help window and then on "LabVIEW Data
Storage"), you'll get to an App Note that explains how LabVIEW stores
its data.  The first part (pages 1-8) explains the data format and the
second part (pages 9-14) explains the format of the type descriptors.

You'll have to parse the type descriptor yourself, but there is an LLB
buried inside vi.lib (vi.lib\Utility\GetType.llb) that you may find
moderately helpful.  There is a VI there named "Get Type Of
Variant.vi" that returns a type descriptor for the real data inside
the variant (if you use this, you may not need the primitive I
mentioned earlier).  If your data uses containers, like the array or
cluster, you'll need to write some parsing code yourself to get to the
nested types.  Once you figure out your data type, you can then
inflate the data.

Hope this helps.

Stephen

Reply via email to