10-12-2015 05:06 AM
Hi. I've been challenged with reading a LabView variant type from a binary file too and this topic has been of great help for me. I wanted to add my findings along with relevant references to help anyone tasked with the same problem.
So, to continue previous comments (new and corrected fields in bold):
Comments:
1. Variant pointer. Couldn't find a reference for this part. So no reliable links on its' structure and meaning so far.
2. Number of Type Descriptors in the file. Reference: Introduction.
3. Type Descriptor Length. Includes the size field itself, may include a control name (as it does in our case) and is rounded up to a multiple of two. References: Introduction, Section "Data Types", text after the tables.
4. Type Description. xx 30 for a string, xx - reserved bytes. Reference: Section "Data Types", second table.
5. Length. FF FF FF FF for fields of variable size. Reference: Section "String, Path, and Picture Data Types".
6. Length of a control name
7. Control name - text string (53 54 52 49 4E 47 - is "STRING" in hex values, the same as 41 42 43 is "ABC" in Data field)
8. Padding as mentioned in 3.
9. Number of type descriptors actually used. There's only 1 type in this file and it's acutally used. Note: If the value is greater than or equal to 32768, it is stored in four bytes [instead of 2] with the high bit set to one. Reference: Introduction.
10. Zero-based index for the Type Descriptor being used. Note: If the value is greater than or equal to 32768, it is stored in four bytes [instead of 2] with the high bit set to one. Reference: Introduction.
11. Length of the Data string
12. Data string ("ABC" in hex values)
13. Padding. Again, couldn't find a reference. Is it always 00 00 00 00 or is there a difference?
Hope this helps someone.
Corrections, additions and comments are appreciated.
10-12-2015 06:37 AM
01-25-2025 07:50 AM - edited 01-25-2025 07:51 AM
Just a short remark. What is called Variant Pointer in the spreadsheet (the first 4 bytes) is simply the LabVIEW version number that created the flattened variant.
1200 0804 means basically: LabVIEW 12.0 (2012, minor release 0) and the 08 means a LabVIEW release (instead of alpha or beta release) and 04 is build number or bug fix release or something like that. As far as flattened variant format goes, only the first byte is really important, the second indicating the minor release or SP level might have an influence on some very obscure data but should usually not change at all. The rest is just cosmetic as it should never change the flattened data format.