I/O Format Specifiers for Reading IEEE 488.2 Binary Blocks
IEEE Binary Block Data — %b
Section titled “IEEE Binary Block Data — %b”An array argument formatted as an IEEE definite-length binary block has a format specifier of the following form:
%[*] [array size] [$S] [b | h | l | I | z | Z] b
| Modifier | Interpretation |
|---|---|
| Default Functionality | The data block received must be in IEEE 488.2 definite-length binary block form. |
* (asterisk) | An asterisk acts as the assignment suppression character. The input is scanned but not assigned to any parameters and is discarded. |
array size | Specifies the maximum number of elements to read from the device. If the argument is a SAFEARRAY, then the array size may be omitted. A # 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 assumed to have 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 assumed to have 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 assumed to have 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 assumed to be in IEEE 754 format. Z - argument is an array of double (64-bit) floating-point numbers.The numbers are assumed to be in IEEE 754 format. |
Example — Definite-length blocks
Section titled “Example — Definite-length blocks”HRESULT hr = S_OK;
short rgData[100];
// IEEE definite-length block of 100 16-bit wordshr = io.Scanf(_T("%100hb"), rgData);
SAFEARRAY* psa = NULL;
// Definite-length block of doubles. Argument is a SAFEARRAY.// No field width is needed as Scanf allocates the SAFEARRAY memoryhr = io.Scanf(_T("%$Zb"), &psa);
// ... use SAFEARRAY result
// IMPORTANT: SAFEARRAY must be destroyedhr = ::SafeArrayDestroy(psa);