LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Null Characters in Flatten to String

Solved!
Go to solution

Hi all,

 

I am using the Flatten to String Function to convert a numerical array to a flattened data string in hexadecimal. When I do this, it adds 6 null characters (zeros) before every array element. How can I flatten my array without the addition of these null characters?

 

Thanks,

Jasmine

0 Kudos
Message 1 of 8
(3,077 Views)

Hi Jasmine,

 

is your question related to Syr's thread?

Best regards,
GerdW


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

I think it is related, but I am a beginner with LabView and programming in general and do not understand the link between our issues and how to solve my problem. I have a link to the section of my vi in which I want the data string to be CA 00 01 F0 02 01 2C DF but is returning 0000 0008 0000 00CA 0000 0000 0000 0001 0000 00F0 0000 0002 0000 0001 0000 002C 0000 00DF instead.

0 Kudos
Message 3 of 8
(3,063 Views)
Solution
Accepted by topic author Jas.D

Change your datatype to U8 (bytes) and wire a false constant to prepend size.

 

WIth a byte array and no size prepended you could also Type Cast

0 Kudos
Message 4 of 8
(3,061 Views)

By default, the Flatten To String adds a length to the beginning for the array/string size.  So you are actually seeing an I32 (4 bytes) prepended to the actual data.

 

6 hex characters of 0?  That is belivable.  That would leave the other 2 nibbles for an appropriate length of your array (up to 255).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 8
(3,054 Views)

Now that I'm looking at your code, that can be simplified A LOT.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(3,045 Views)

That worked, thank you so much Darin.K

0 Kudos
Message 7 of 8
(3,026 Views)

Thank you crossrulz!! Once I have the rest of my vi figured out I will consider this for simplifying it.

0 Kudos
Message 8 of 8
(3,024 Views)