Jump to content

Database Variant To Data function

Recommended Posts

Does anyone know how to get and be able to use the "Database Variant To Data" XNode without installing the Database Connectivity toolkit?  I'm not using databases in my project, but that function is a really handy, compact way of converting an array of variants into a cluster.  Or is there another way that's equally neat and simple?


Thanks.   -Joe


Link to comment

Well I believe LabVIEW 2014 now includes the Database Connectivity toolkit so it can be used there.  Is there a version of LabVIEW you need that is not 2014?  I can try to take the 2014 version and back save it to what you need.


BTW looking at the XNode it is a pretty manual process of indexing each element from the variant using an Index array (not sure why a for loop wasn't used) then it uses Variant to Data for each, element and a bundle at the end.


I've made a recent entry on the Idea Exchange about this.  



Here’s the VI I’m experimenting with, referred to in that link:

attachicon.gifArray of Variants to Cluster of Variants.vi


It converts arrays (up to size 50) into clusters of variants, which can be then converted to clusters.

Did you intentionally miss the case when you cluster has 2-4 elements?


Link to comment



Alright never mind I just made the XNode from scratch.  It supports LabVIEW 2011+.  It supports breaking the wire if the input is not a cluster, it does clusters in clusters, it has the type adaption on the output, and the icon changes color, based on the color of the cluster wired into it.  I also built an EXE using it just to make sure that worked and it does.  All source is included with no passwords.  To see how it works just open the XNode Template.vi.  It will basically just set the cluster size and change the terminal types to what was wired.

Array Of Variant To Cluster XNode.zip

  • Like 2
Link to comment

Question: can Xnodes be recursive?  If the cluster has a sub cluster, and the corresponding variant in the array contains, not a cluster, but another array, can the Xnode recursively call itself?  

Okay I don't think so.  I tried a bit and weird things happened with locking the library, but I think it could be possible for an XNode to script itself, and contain in it a copy of its own XNode but you wouldn't want to.  An XNode is a library and having an instance of the XNode somewhere locks the whole library.  Like a XControl having a copy will lock the facade from editing.  So having a copy of itself would lock itself and may make editing impossible.  It's like asking can an XControl contain an XControl that is itself?  Well maybe, but don't ever try it.


As for your other question I just tried this with the structure you described and it worked just fine.  I had a cluster of three elements, one element was just a numeric, the next was an array of a cluster with one element in it that is a numeric.  The third element was a cluster with one element, which was an array of a cluster, with one element which was a string.  I turned this into an array of variants with the Data to Variant then back again with this XNode and all values came in.  What structure did you try that it didn't work with?

Link to comment

The problem is when I recursively dive into sub clusters and convert them into arrays of variants (inside individual elements of the outer array).  For example, if I am setting a cluster that matches the JSON text,




then I will end up with an array of two Variants, each of which is an array of two Variants.  

Link to comment
  • 10 months later...

To follow up on my original post: now that the Database Variant To Data function is included with Labview, I find that I can't go back to using it because it does not support cluster elements that are arrays.  I've got used to hooovahh's Array Of Variant To Cluster XNode and have built code that processes clusters of arrays of clusters and so on.


Link to comment

Oh well sorry I showed you a powerful tool that is something to be cautious about.  The source is quite easy, just look at the template.  All that is really needed is to set the number of cluster elements to the right number and it should work as a non-xnode which can be invoked as a merge VI.  Just don't forget to set that number of cluster elements everytime the cluster size changes.

Link to comment
  • 3 years later...

Hi hooovahh -  I'm upgrading my operation from LV 2015 to LV 2018 and would like to redo your Array Of Variant To Cluster XNode as a malleable VI.  Do you think that makes sense, and do you have any pointers that would improve my chances of success?   :-)

Thanks very much.   -Joe

Link to comment

You will not be able to create a VIM that operates the same way my XNode does.  This is because the technique I used was to use the Array to Cluster function, and setting the number of elements using scripting.  However using the OpenG method you can do this another way.  It is likely less efficient and takes longer but if you want a VIM that does it this should do the trick.

Array Of Variants to Cluster.vim

Link to comment

Thanks hooovahh, I tried it in Labview 2018.  Using the OpenG 'Array of Vdata to Vcluster_ogtk.vi' followed by the Variant To Data function works in my application, without using a malleable VI.  Using the Database Variant To Data function alone can be wired successfully but generates a run-time error because my cluster includes some elements which are arrays.  Thanks again for the hint.


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.

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.