ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

converting data from a generic LabVIEW object to a string like the Object.ToString method in .NET

Solved!
Go to solution

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.

0 Kudos
Message 1 of 5
(5,222 Views)
Solution
Accepted by bruce008

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,

 

Tom L.
0 Kudos
Message 2 of 5
(5,212 Views)

@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.

Message 3 of 5
(5,205 Views)

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.

0 Kudos
Message 4 of 5
(5,199 Views)

@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,



Tom L.
0 Kudos
Message 5 of 5
(5,175 Views)