Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Flatten To String Function

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

Owning Palette: Data Manipulation Functions

Requires: Base Development System

Converts the anything input to a flattened data string of binary values. You also can use this function to convert the byte order, or endian format, of the data in the flattened data string.

Details  

anything contains the data you want to convert to a UTF-8 JSON string. This input accepts arrays and clusters of Booleans, floating-point numbers, and strings. anything can also accept an array of clusters, or a cluster of arrays, of these data types.

Cluster elements may be named or unnamed, but not a combination of both. If cluster elements are named, then each name must be unique to that cluster. If you wire an unsupported data type, LabVIEW breaks the VI.
prepend array or string size? indicates whether LabVIEW includes data size information at the beginning of data string when anything is an array or string. If prepend array or string size? is FALSE, LabVIEW does not include the size information. The default is TRUE. prepend array or string size? only controls the top-level data size information. Arrays and strings in hierarchical data types such as clusters always include size information.
byte order sets the endian format of the data in the resulting flattened string. Byte order, or endian form, indicates whether integers are represented in memory from most significant byte to least significant byte or vice versa.

0big-endian, network order (default)—The most significant byte occupies the lowest memory address.
1native, host order—Uses the byte-ordering format of the host computer.
2little-endian—The least significant byte occupies the lowest memory address.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
data string is the flattened data generated by the function. data string might contain header information before each non-scalar component describing its size. Such a string can be stored in a file or sent over a network. If you send the string over a network, the receiver must be able to interpret it. Usually, LabVIEW stores data as noncontiguous, indirectly referenced pieces. This function copies the data in LabVIEW form into a contiguous buffer data string. Use the Unflatten From String function to convert a data string back to any data type.
type string (7.x only) is visible only if the terminal is already wired from a previous version of LabVIEW or if you right-click the function and select Convert 7.x Data from the shortcut menu. type string (7.x only) is an encoded binary description of data string. type string (7.x only) is not the same as the type input in the Unflatten From String function. If type string (7.x only) cannot represent the data type wired to anything, this function returns an error.
error out contains error information. This output provides standard error out functionality.

Flatten To String Details

Use the Type Cast function for conversion of data types that does not result in flattened data.

If you need to flatten type descriptor data to a string that is readable by LabVIEW 7.x or earlier, right-click this function and select Convert 7.x Data from the shortcut menu. In Convert 7.x Data mode, this function shows the type string (7.x only) output and displays the icon for this function with a red 7.x on it. LabVIEW 7.x and earlier stores type descriptors in 16-bit flat representation. LabVIEW 8.0 and later stores type descriptors in 32-bit flat representation. National Instruments recommends reworking any application that uses the Convert 7.x Data mode as a long term solution.

If you need to flatten Boolean data to a string that is readable by LabVIEW 4.x or earlier, right-click this function and select Convert 4.x Data from the shortcut menu. The Convert 4.x Data shortcut menu item is visible only if you wire Boolean data to anything. In Convert 4.x Data mode, this function writes the data in LabVIEW 4.x data storage layout and displays the icon for this function with a red 4.x on it. LabVIEW 4.x and earlier stores Boolean data in two bytes unless the data is in an array, in which case LabVIEW stores each Boolean element in a single bit. LabVIEW 5.0 and later stores Boolean values in a single byte, regardless of whether it is in an array. National Instruments recommends reworking any application that uses the Convert 4.x Data mode as a long term solution.

If you use this function to flatten variant data, LabVIEW flattens the variant and all its contents, including attributes. However, if you use the Variant To Flattened String function, LabVIEW flattens only the variant and discards any attributes.

If you use this function to flatten data from a custom control or indicator that you saved as a type definition, the function strips the type definition of its type definition wrapper. If you do not want to strip this wrapper, right-click the function and select Expose Typedefs from the shortcut menu. The Expose Typedefs shortcut menu item is visible only if you wire data to type string (7.x only).

Note  The string created by the Flatten To String function is a LabVIEW string. If prepend array or string size? is TRUE, the LabVIEW string has a 4-byte (I32) number at the beginning of the string that tells how long the string is. This enables a LabVIEW string to include NULL characters [ASCII character zero (0)]. If you pass a LabVIEW string to external code and use it as a C string, NULL characters embedded in the string may cause problems, since C strings are interpreted as terminating at the first NULL character.

 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit