Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated

Why does a String in a Cluster have Four Extra Bytes?

Primary Software:
Primary Software Version: 8.0
Primary Software Fixed Version: N/A
Secondary Software: N/A

I have a string of a known length in a cluster and I am inputting that cluster into the Flatten to String function. When I look at the length of the resultant string, why are there four extra bytes compared to the actual string length?

Strings in clusters always contain the string length information when flattened. That information is stored as a U32 integer. Therefore, the length of the flattened string is the length of input string (n number of bytes) plus the string length information (four bytes). The resultant string length is n + 4 bytes.

You can view this information if you wire an indicator to the output of the Flatten to String function and change the indicator to show the hex values of the string. The attached VI demonstrates this functionality:

This shows on the front panel the enclosed string's actual length as well as the output string from the Flatten to String function. You can see on the actual front panel how there are four bytes (0000) prepended to the hexadecimal flattened string, which results in a longer string length. This also happens whether or not the Prepend Array or String Size? setting is set to True of False:

Related Links:
KnowledgeBase 3JDINGHB: In LabVIEW, Is There a Maximum Length of a String?
Developer Zone Tutorial: Arrays and Clusters



Report Date: 01/02/2009
Last Updated: 12/04/2013
Document ID: 4T1B42GF

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit