03-09-2020 10:08 AM
Pretty straightforward question: Now that malleable and polymorphic VIs both exist for users, is it possible to make your own resizeable VIs? I was trying to make a subVI that is basically just "Build Array" but instead is "Build Variant Array" where every element is explicitly converted to a variant so that you can have different data types in the same array. I know in that specific instance I could do something like bundle all the items and then use "cluster to variant array", but I still want to know for future applications if this is something that could be done.
Bonus question: is it possible to make subVIs with custom shapes like the math functions? Since Build Array is smaller than the size of a normal subVI node, it makes me wonder if we could make any subVI with different sizes or shapes.
Solved! Go to Solution.
03-09-2020 11:05 AM
@maluigario wrote:
is it possible to make your own resizeable VIs?
Xnodes can be used, but they are experimental and unsupported. Look in lavag.org for more information.
@maluigario wrote:
I was trying to make a subVI that is basically just "Build Array" but instead is "Build Variant Array" where every element is explicitly converted to a variant so that you can have different data types in the same array.
Me thinks regular build array with a coercion may work.
@maluigario wrote:
Bonus question: is it possible to make subVIs with custom shapes like the math functions? Since Build Array is smaller than the size of a normal subVI node, it makes me wonder if we could make any subVI with different sizes or shapes.
Modify the icon of a subVI to a non-square shape; use the icon editor.
mcduff
03-09-2020 11:20 AM
In the icon editor, you can Show Terminals. Use this feature to design a non-square shape that matches your terminal pattern so that connected wires appear to be connected to your icon rather than floating next to it.
You can see here that my addition node is a bit smaller than the LabVIEW node and the wire doesn't appear to connect.
You can make the icon any shape you want.
03-09-2020 11:21 AM
Yes, I was also going to say xnodes for the "resizeable" part of the question.
The main advantage of arrays is that they perform so well exactly because all elements share all properties (including datatype) and differ only value. They are stored contiguous in memory. You want to throw all that away. For what?
If you want to store different datatypes as variants in an array and are planning to get them out later, you also need to maintain info about the datatype of each element, else it basically turns into a write-only memory. 😄
Can you explain in more details what you are actually trying to achieve?
03-09-2020 11:30 AM
We have an automated test setup that temporarily stores the results of each test run in a configuration file using the NI_LVConfig library's "Read Key" and "Write Key" subVIs, and some tests have a number of items that get written in a single step. Rather than having a long chain of 20 of either one in a row, I created a malleable VI that takes an array of strings and an array of variants to read and write the data. I expect each variant value to keep track of its underlying data type; as I loop through the variant array of values, I call the NI_Data Type library's "Get Type Information" subVI to ensure only supported data types are stored in the configuration file. At the end of the test, the values are read back, converted to SQL-compliant data, and pushed to a database. I was just looking for a convenient way to take a bunch of values of different types and stuff them into a single array to then pass to either of these subVIs.
03-09-2020 11:47 AM
@maluigario wrote:
We have an automated test setup that temporarily stores the results of each test run in a configuration file using the NI_LVConfig library's "Read Key" and "Write Key" subVIs, and some tests have a number of items that get written in a single step. Rather than having a long chain of 20 of either one in a row, I created a malleable VI that takes an array of strings and an array of variants to read and write the data. I expect each variant value to keep track of its underlying data type; as I loop through the variant array of values, I call the NI_Data Type library's "Get Type Information" subVI to ensure only supported data types are stored in the configuration file. At the end of the test, the values are read back, converted to SQL-compliant data, and pushed to a database. I was just looking for a convenient way to take a bunch of values of different types and stuff them into a single array to then pass to either of these subVIs.
Have you tried MGI's read-write anything? Look on VIPM for it. I use it to write a "clustersaurous" to an text like ini file. I did something similar to you before and got tired of wrting elements one-by-one. See snapshot.
mcduff