LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create array function working with any data type

Solved!
Go to solution

Hello everybody,

 

is it possible to create array functions that can handle any data type inside the array, like the NI-Array functions do? The output data type would always adapt to the input type. Like this it would be possible for example to create a function that returns the 1st array element, no matter what type it is.

0 Kudos
Message 1 of 11
(3,179 Views)
Solution
Accepted by timeDelay

As of LabVIEW 2017, we have Malleable VIs.  Just save your VI as a vim, make sure it is set to be inlined and reentrant, and then you are good to go.  There are a who bunch of functions that were released from 2017SP1 and 2018 you can use as examples.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 11
(3,164 Views)

All right. Sounds like for me using LabView 2015 there is no solution.

0 Kudos
Message 3 of 11
(3,152 Views)

Sure, just make all VI's as Variants. 😄 Ofcourse you'd have to convert it afterwards to get your data back ...

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 4 of 11
(3,143 Views)

Is polymorphic vi available in 2015?

http://zone.ni.com/reference/en-XX/help/371361P-01/lvhowto/using_polymorphic_vis/

---------------------------------------------
Certified LabVIEW Developer (CLD)
0 Kudos
Message 5 of 11
(3,136 Views)

@Frozen wrote:

Is polymorphic vi available in 2015?

http://zone.ni.com/reference/en-XX/help/371361P-01/lvhowto/using_polymorphic_vis/


Polymorphic VIs have been around for a VERY long time.  The problem with them, though, is you have to actually define a VI for each possible data type you want to support.  VIMs are a single VI that adapt to the input data type.

 

The other option, not exactly supported, is to make an XNode.  For more details, I recommend you visit lavag.org.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 11
(3,122 Views)

Create -> New... -> Polymorphic VI

You'll need to create a VI for each datatype that you want to support. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 11
(3,121 Views)

@timeDelay wrote:

All right. Sounds like for me using LabView 2015 there is no solution.


2015 will run a vim  you will need to create it in 2017 or later and backsave for 2015 (This is not guaranteed to be bug free if you need a Type Specialization Structure but, you probably don't) 

Capture.PNG


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 11
(3,115 Views)

@JÞB wrote:

@timeDelay wrote:

All right. Sounds like for me using LabView 2015 there is no solution.


2015 will run a vim  you will need to create it in 2017 or later and backsave for 2015 (This is not guaranteed to be bug free if you need a Type Specialization Structure but, you probably don't) 

 


It won't adapt like the OP wants.  It will just run as a normal VI.  I know because I did this with a LabVIEW 2016 VI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 11
(3,107 Views)

@timeDelay wrote:

Like this it would be possible for example to create a function that returns the 1st array element, no matter what type it is.


This function is called "index array", but unfortunately you get the first element for 1D, first row for 2D first plane for 3D. etc. Since you seem to want only the first scalar elements (assuming memory order), the code will depend on the number of dimensions and you would probably need the type specialization structure and LabVIEW 2017+.

 

What is the practical use of that function? Why do you need it and why isn't it sufficient to just use index array with a zero wired to all indices?

0 Kudos
Message 10 of 11
(3,102 Views)