11-19-2024 12:11 AM
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
Solved! Go to Solution.
11-19-2024 01:05 AM - edited 11-19-2024 01:05 AM
11-19-2024 01:21 AM
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.
11-19-2024 01:30 AM
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…
11-19-2024 02:40 AM
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)
11-19-2024 03:21 AM
You can solve it like this, but it'll be a little work. 🙂
11-19-2024 03:24 AM
Wow! that's a nice solution although it involves some work!!
Thanks for your help.
11-19-2024 04:11 AM - edited 11-19-2024 04:18 AM
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!
11-19-2024 04:21 AM
This is what I am exactly looking for!! Thanks a lot😀