Jump to content

Flatten & Unflatten


Recommended Posts

Anyone notice the new terminals on "Flatten to String" & "Unflatten from String"? Finally, I can get rid of all that byte swapping and array length code in my TCP communication applications.

Incase you can't find the functions, Data manipulation is now a sub-palette of Numeric.

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.

Link to comment

Yeah I noticed them... unfortunately it means re-doing a lot of my code :headbang:

Has anyone found a workaround for trying to unflatten a null string into a cluster datatype so the cluster is empty? The unflatten function now yields error 42 (generic error), which I suppose can be ignored, but that may be a bit cumbersome.

Link to comment
Yeah I noticed them... unfortunately it means re-doing a lot of my code :headbang:

Has anyone found a workaround for trying to unflatten a null string into a cluster datatype so the cluster is empty? The unflatten function now yields error 42 (generic error), which I suppose can be ignored, but that may be a bit cumbersome.

What do you mean by a null-string? A zero length string?

And what type of cluster do you have. Does it include a string (where length information is stored with the data)

Success Ton

Link to comment
  • 2 months later...
What do you mean by a null-string? A zero length string?

And what type of cluster do you have. Does it include a string (where length information is stored with the data)

Success Ton

Yes, a null string meaning the zero-length string constant (shown as a little square quote) located on the palette.

I have all types of cluster, usually just different data, and usually not including a string where length information is stored with the data

Link to comment
Yes, a null string meaning the zero-length string constant (shown as a little square quote) located on the palette.

I have all types of cluster, usually just different data, and usually not including a string where length information is stored with the data

The fact that Unflatten From String returns an error when you try to unflatten an empty string into a cluster is good -- this is a feature. If you use Flatten To String to flatten an "empty" cluster, you will not get an empty string (since even a cluster with default/null vales still has data). If you want a different behavior, then test for an empty string and then pass an empty cluster out.

Also, the term "null", used in the context of string data, usually refers to the character whos decimal value is 0. This will appear as \00, in slash code mode. You will find that if you flatten an "empty" cluster, you will get a lot of null characters in your string data.

Cheers,

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.