LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Static VI ref with variant Values converting to concatenated String

Solved!
Go to solution

CatDoe_0-1669666265013.png

 

How can I convert the variant array to a concatenated string? I am trying to format the global variable for output to a text file. The global variable has too many variables to manually add each to an array. The report and ring can be removed from the global variable if needed -- I tried this and had no luck. I would prefer to leave the report and ring in the global variable to avoid having to make more global variables.

 

VI's made with LabVIEW 2021 SP1. 18 backdated version also included.

 

0 Kudos
Message 1 of 5
(1,134 Views)

I think you will need to use the Data Type Parsing VIs to make a case for every variable type and then convert each one to a string individually.  You basically have a modified version of this problem where using those VIs is the solution.

 

If you put everything in the Global into a giant cluster you could use the MGI write anything function on it.

0 Kudos
Message 2 of 5
(1,101 Views)

You could use an existing package that formats Variants in text form, such as JSONtext.

0 Kudos
Message 3 of 5
(1,075 Views)
Solution
Accepted by CatDoe

Hello CatDoe,

 

I did not want to take credit for someone else's work, so I searched up the original post which provided the solution for me.

https://forums.ni.com/t5/LabVIEW/How-to-get-a-variant-s-value-as-a-string/td-p/1898883/page/2

Using the VIs posted by Paul Cardinale worked perfectly for me.

 

For your application you should be able to use the Variant Text.vi directly like this.

VariantToString.png

Message 4 of 5
(1,050 Views)

Thank you kghzvi! This was super easy to adapt for my needs!

 

Note to future readers -- this VI puts both \r\n and an end of line constant at the end of the string. If you want a clean string without these additional characters you need to modify the end.

 

Helpful notes to remove line breaks and new line characters:

Convert String with Line Breaks to Single-Line String in LabVIEW - NI

0 Kudos
Message 5 of 5
(1,034 Views)