LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Convert Cluster to String

Solved!
Go to solution

Here is a VI to convert any data to a String, and the VI to convert the String back to a Variant.  Use the Variant to Data function to convert back to your data type.  I use LV 8.2, please rate if it helped you. Thanks.

 

-Branson

 

0 Kudos
Message 1 of 10
(19,347 Views)

Great for you to provide VIs. However, if you wish to get some feedback you should not lock the VIs. I for one, will not use a VI created by a user on this forum unless I can see the code. After all, how do I know that they're not trying to deliver a virus?

 

Also, how is the VI any different that doing this:

 

 

EDIT: Updated picture as I forgot to concatenate the data string. 

Message Edited by smercurio_fc on 10-10-2008 02:59 PM
Message 2 of 10
(19,331 Views)

Thanks for you reply smercurio_fc, point taken.  Here are the VI's without passwords.  As you can see, no foul play.  FYI respectfully, you example does convert to string, but is not reliable to convert back to variant.

 

-Branson

Download All
0 Kudos
Message 3 of 10
(19,296 Views)

Still password protected.

 

Let me take a step back here. What is the main objective here? Are you trying to save the cluster to file, or something? Where are you using these VIs?

0 Kudos
Message 4 of 10
(19,264 Views)

2nd try of attachments with no passwords...don't know what I missed the first time...and wish I knew how to edit my original post to replace those attachments.

 

Purpose is to convert any form of labview data to a string.  I'm using it to store information about an image taken with "fingerprint" information.  Sorry for the multiple posts w/ attachments.  I am still new to these forums.

 

-Branson

Download All
0 Kudos
Message 5 of 10
(19,258 Views)
Solution
Accepted by Branson

OK. Can open them now.

 

From a programmatic perspective and usability perspective, what do you see as the main advantage of this method as opposed to using the Flatten To String and Unflatten From String functions without going through an intermediate variant? Or, perhaps, the Flatten to XML/Unflatten from XML functions. In other words, what are the pros and cons of your method as opposed to this method:

 

One clear advantage of your method clearly is that you do not need to wire in the data type, as you need to do with the Unflatten From String function. Were you addressing other concerns?

Message Edited by smercurio_fc on 10-12-2008 11:04 AM
Message 6 of 10
(19,224 Views)

I didn't know about Flatten To String or Flatten to XML until you mentioned it.  I found the VIs and compared them all together using a 1d array of error clusters.  There was no difference in terms of time to convert to string and back.  But there was a huge difference in terms of amount of data being passed. 

 

Using 10 cluster elements in the array....

Flatten to String passed 94 bytes

toString and Stringto VI's passed 316 bytes

Flatten to XML passed 2469 bytes.

 

I think I will use your suggestion for the Flatten To String function to conserve space.

 

Thanks 

Branson

0 Kudos
Message 7 of 10
(19,194 Views)

Well, it's always a good day when you can learn something new!

 

I like the idea of being able to not have to wire the datatype as you need to do with the Unflatten functions that are built into LabVIEW. That's one advantage of the method you have, but there's the rub of a fair amount of extra code. I think I'll tinker with this with my spare time...

0 Kudos
Message 8 of 10
(19,176 Views)

The "to_string1.vi" didn't really do what I wanted... Just output a plain Text I can write to a file.

 

 

(You will need the OpenG)

 

to_String1.png

Message 9 of 10
(17,452 Views)

f you need to write a cluster to File (the main reason I see to convert it to text), then I would use the Read/Write Anything to File VIs from MGI. You can download them using the VI Package Manager. You can wire a custom cluster straight into this VI and then read it out using the variant to data function. Data is saved to a readable text file with the item names. 

 

Write Anything

 

Read Anything

 

-Hunter

Message 10 of 10
(17,241 Views)