Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Flatten To String

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

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 can be any data type.
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 VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurred before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.
status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE.
code is the error or warning code. The default is 0. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.
source specifies the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.
data string is the flattened data generated by the function. data string might contain header information before each nonscalar 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 only visible 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. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out front panel indicator and select Explain Error from the shortcut menu for more information about the error.
status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred.
code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.
source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning.

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 only visible if you wire a Boolean data type 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 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 only visible if you wire 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? (T) 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.

Resources


 

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