Object: BinaryBlock
- Updated2024-09-12
- 2 minute(s) read
(BinaryChannelFormatter | File) > Object: BinaryBlock
Object: BinaryBlock
Use the BinaryBlock object to access channel data from a binary file.
A BinaryBlock can contain one or more DirectAccess channels. The channel values are organized columnwise in this block. The number of bytes in each column depends on the channel type. For example, if a block contains three channels with 32-bit integer values, the first four bytes are the first value of the first channel, the second four bytes are the first value of the second channel, and the third group of four bytes are the first value of the third channel. The fourth group of four bytes are the second value of the first channel, and so on.
You read the contents of a binary file as follows:
- position the file pointer at the section to be read,
- use the File.GetBinaryBlock method and assign the return value to a variable,
- add a DirectAccess channel to the BinaryBlock for each channel to be read,
- read the separate values from the channel or assign the entire DirectAccess channel to a channel group.
If you do not want to read all the channels, create DirectAccess channels for the channels you want, and use the BlockWidth property to adjust the block width. The block width is usually the sum of the single channel widths.
| Note The file pointer of the binary file does not move when a BinaryBlock is read. |
The following example reads a binary file that contains four channels with 32-bit integer values:
Dim oBlock : Set oBlock = File.GetBinaryBlock() Dim oChn1 : Set oChn1 = oBlock.Channels.Add("Channel1", eI32) Dim oChn2 : Set oChn2 = oBlock.Channels.Add("Channel2", eI32) Dim oChn3 : Set oChn3 = oBlock.Channels.Add("Channel3", eI32) Dim oChn4 : Set oChn4 = oBlock.Channels.Add("Channel4", eI32)