I/O Format Specifiers for Writing IEEE 488.2 Binary Blocks
IEEE Binary Block Data — %b and $B
Section titled “IEEE Binary Block Data — %b and $B”An array argument formatted as an IEEE binary block has a format specifier of the following form:
%[array size] [$S] [b | h | l | I | z | Z] [b | B]
| Modifier | Interpretation |
|---|---|
| Default Functionality | The data block is sent as an IEEE 488.2 definite-length binary block. The array size field specifies the number of elements (by default, bytes) in the block. |
array size | Specifies the number of elements in the associated array argument. If the argument is a SAFEARRAY, then the array size may be omitted, in which case the number of elements sent is determined from the size of the SAFEARRAY itself. An asterisk (*) may be present in lieu of an integer array size modifier, in which case an extra int argument supplies the value. |
$S | The argument is assumed to be a SAFEARRAY. |
length modifier | If no length modifier is specified, then the argument is assumed to be an array (or SAFEARRAY if $S is used) of BYTE (8-bit) integer. b - argument is an array of BYTE (8-bit) integer.h - argument is an array of short (16-bit) integer.The array size indicates the number of 16-bit words, rather than the number of bytes.As per the 488.2 binary block standard, the data is sent with big-endian byte ordering. Byte-swapping is automatically performed on all elements in the array. l - argument is an array of long (32-bit) integer.The array size indicates the number of 32-bit words, rather than the number of bytes.As per the 488.2 binary block standard, the data is sent with big-endian byte ordering. Byte-swapping is automatically performed on all elements in the array. I - argument is an array of __int64 (64-bit) integer.The array size indicates the number of 64-bit words, rather than the number of bytes.As per the 488.2 binary block standard, the data is sent with big-endian byte ordering. Byte-swapping is automatically performed on all elements in the array. z - argument is an array of float (32-bit) floating-point numbers.The numbers are sent in IEEE 754 format. Z - argument is an array of double (64-bit) floating-point numbers.The numbers are sent in IEEE 754 format. |
b | Data is sent as an IEEE 488.2 definite-length binary block. |
B | Data is sent as an IEEE 488.2 indefinite-length binary block. A linefeed character (\n) is sent after the last byte of the block. |
Example — Definite and indefinite-length blocks
Section titled “Example — Definite and indefinite-length blocks”HRESULT hr = S_OK;
short rgShortData[] = { 1.1, 1.2, 1.3, 1.4, 1.5 };
// IEEE definite-length block of 3 16-bit wordshr = io.Printf(_T("%3hb"), rgShortData);
// IEEE indefinite-length block of all 5 16-bit words// Number of elements specified as a variableint nCount = 5;hr = io.Printf(_T("%*hB"), nCount, rgShortData);
CComSafeArray<double> saData;saData.Add(1.1);saData.Add(1.2);saData.Add(1.3);
// Definite-length block of 3 doubles. Argument is a SAFEARRAY.// No field width supplied, so count is determined from the SAFEARRAY itself.hr = io.Printf(_T("%$Zb"), saData.m_psa);