03-11-2014 11:25 AM
Is there a way to do that?
Specifically, I want to print my monitor configuration which LabVIEW returns as an array of clusters of numbers and clusters of numbers. I can manually write code to convert that data to a string but if there's an automatic way to convert that to a string, that would sure save some time.
Solved! Go to Solution.
03-11-2014 11:36 AM - edited 03-11-2014 11:47 AM
Hi Bruce,
The Flatten to String function (available in the strings palette) should do what you've described. If you're looking for a more human-parsable string output I'd recommend the flatten to XML or JSON functions, found in the same location.
-Edit- If you're using LabVIEW 2012 or older, I don't believe you'll have access to the shipping flatten to JSON function, although if you prefer that format there is a community toolkit available here:
Interactive Internet Interface: JSON Toolkit for LabVIEW.
https://decibel.ni.com/content/groups/interactive-internet-interface-json-toolkit-for-labview.
Regards,
03-11-2014 11:41 AM - edited 03-11-2014 11:41 AM
@0utlaw wrote:
Hi Bruce,
The Flatten to String function (available in the strings palette) should do what you've described. If you're looking for a more human-parsable string output I'd recommend the flatten to XML or JSON functions, found in the same location.
Regards,
I think you are misunderstanding. He doesn't want to flatten to a string necessarily, but give an object a string representation with some meaning. Unfortunately, a generic LabVIEW class does not have this method build in. You can, however, create a base class that all your objects inherit from which has a dynamic dispatchmethod called toString.
03-11-2014 11:49 AM
I was looking for a human-readable string, but you did answer my question perfectly so I have to accept your answer and ask again! I'll wait awhile.
03-11-2014 12:20 PM
@GregFreeman wrote:
@0utlaw wrote:
Hi Bruce,
The Flatten to String function (available in the strings palette) should do what you've described. If you're looking for a more human-parsable string output I'd recommend the flatten to XML or JSON functions, found in the same location.
Regards,
I think you are misunderstanding. He doesn't want to flatten to a string necessarily, but give an object a string representation with some meaning. Unfortunately, a generic LabVIEW class does not have this method build in. You can, however, create a base class that all your objects inherit from which has a dynamic dispatchmethod called toString.
Hello Greg,
You're right- Bruce indicated he was looking to convert a cluster of numerics, which may or may not have been class data, so I was interpreting "object" to mean a more general GObject (well, maybe not specifically, but that encapsulates the cluster in this case) rather than a class. Your suggestion for adding a base utility class containing generic methods like this is also spot-on.
Best Regards,