LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variant data as readable string

Solved!
Go to solution

In the below screen shot i just converted a cluster data to variant .

I want to get the variant data as string as shown in the string indicators (Which i manually copied and pasted).

I don't want to use the variant to data by specifying the data type. I am using to xml string but its very cluttered.

I am looking for a node which do that. I don't want a complex implementation. 

 

My use case it to write this data to a text file for debugging purpose.

 

I came across this below thread but no satisfactory answer.

https://forums.ni.com/t5/LabVIEW/How-can-I-get-a-variant-s-string-data/td-p/464587

 

LabVIEW_zS1mkaf4b7.png

0 Kudos
Message 1 of 9
(157 Views)

Hi Samuel,

 

is there a reason to use variants?

 

Suggestion:

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(133 Views)

Thanks for your suggestion, Json is ok but it do not supports all types of data as xml supports also need to a be parsed to to get a nice look else its one line string.
The reason is very simple it supports all data types and easy to read in very compact manner. For a application development perspective there many alternatives. Also at first it look very easy to grab those strings from that control but seems that's not the case.

In some use case where debugging are disabled (Plugins) I use a dialog box along with format into string to see the data in that case this will be very helpful. Off course i can live without this feature but its nice to have if its very easy to implement. I don't prefer if it's a complex implementation.

0 Kudos
Message 3 of 9
(119 Views)

Hi Samuel,

 


@Samuel_James wrote:

Thanks for your suggestion, Json is ok but it do not supports all types of data as xml supports also need to a be parsed to to get a nice look else its one line string.


JSON was just a suggestion, you can convert to XML as well when you use the right function!

And you can use any string function you like when you want to "beautify" the resulting string after JSON/XML conversion…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(110 Views)

Alternatives are fine. But the short conclusion is that there is no direct way to get those stings from variant. Alright. It would be great to have a script to indirectly copy strings from variant control. (which simulate manual copying of strings)

0 Kudos
Message 5 of 9
(88 Views)
Solution
Accepted by Samuel_James

You can solve it like this, but it'll be a little work. 🙂

Yamaeda_0-1732008067602.png

Yamaeda_1-1732008093362.png

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 9
(77 Views)

Wow! that's a nice solution although it involves some work!!
Thanks for your help.

Message 7 of 9
(71 Views)
Solution
Accepted by Samuel_James

You missed this thread and the post: https://forums.ni.com/t5/LabVIEW/Convert-cluster-to-readable-string-and-string-to-data-but-not/m-p/4...

 

His solution is basically a VI I posted somewhere else in this forum but can't find it quickly.

 

And no this is not suitable to reply data back into a variant. For that you really want to use one of the proper string data formats like JSON or XML.

 

And if your complaint is that they don't support every possible LabVIEW datatype, please tell us what datatype you specifically think of. Most of them (like refnums for instance) make no sense to persist into a data stream. They are just like a pointer pointing somewhere and can't be reconstructed from that at all!

Rolf Kalbermatter
My Blog
Message 8 of 9
(48 Views)

This is what I am exactly looking for!! Thanks a lot😀

0 Kudos
Message 9 of 9
(35 Views)