Jump to content

Any type data input


Recommended Posts

You should ask for generic VIs, or XNodes   :D .

 

Okay but seriously the options today are to use polymorphic VIs, where you write your code to work on each type of array you expect, and have it auto pick the right one based on the type wired to it, or you work with variants and expect the user to convert the variant back into the array of their type that they put in.  LabVIEW is a strictly typed language, and there is no easy way to do what you want in a scalable way.

 

For examples look at OpenG.  Their array tools work with multiple data types because of polymorphc VIs, but if you give it an array of a type def there isn't a VI for, it uses the array as a variant and you need to convert the variant back into the data type you gave it.

 

A very experimental, not official technology is XNodes which NI uses to accomplish something like this.  If NI ever officially releases XNodes I would recommend you use them, until then you're stuck with variants, and polymorphic VIs.  Here is an example of taking the OpenG array tools and turning them into XNodes which accept any array data type.  Again, not recommended yet.

Link to comment

Ok, let me explain again with more infos.

 

My sub vi is attached.

 

As you all can see, i just manipulate array, doesnt matter which type it is, like any array function in array pallete. Butttt, when I plug in the input one array of string, i get error, because the data type is different. This error doesnt appear when we use "index array", for example. 

post-53833-0-32741700-1438357251.png

Link to comment

I heard a wise man say once, regarding your exact question.

You should ask for generic VIs, or XNodes   :D .

 

Okay but seriously the options today are to use polymorphic VIs, where you write your code to work on each type of array you expect, and have it auto pick the right one based on the type wired to it, or you work with variants and expect the user to convert the variant back into the array of their type that they put in.  LabVIEW is a strictly typed language, and there is no easy way to do what you want in a scalable way.

 

For examples look at OpenG.  Their array tools work with multiple data types because of polymorphc VIs, but if you give it an array of a type def there isn't a VI for, it uses the array as a variant and you need to convert the variant back into the data type you gave it.

 

A very experimental, not official technology is XNodes which NI uses to accomplish something like this.  If NI ever officially releases XNodes I would recommend you use them, until then you're stuck with variants, and polymorphic VIs.  Here is an example of taking the OpenG array tools and turning them into XNodes which accept any array data type.  Again, not recommended yet.

 

In short, we as G developers can not make our own functions that act excatly like the array primitives in LabVIEW.

This techniques listed above by Hoova are the ones to focus on if you want that same kind of behavior.

 

I vaguely recall that someone once made a tool which would make the poly VI stack for you, for all available data types; this way you don't have to replicate your VI over and over and make the poly.

But I can not recall where that would be. Maybe someone else could chime in

Link to comment

Not sure if you were talking about me or not, but I had forgotten that I made such a tool, which I never got to finish here:

 

https://lavag.org/topic/16003-another-create-polymorphic-vi/

 

If I were to write that again I would have done things differently, but the tool mostly works.  Give it a template, tell it what controls to replace, with what other controls, and then a bunch of VIs were made for each control type you picked.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.