![]() | I/O Format Specifiers for Readings Raw Binary Data |
An array argument formatted as raw binary data has a format specifier of the following form:
%[*] [array size] [!ob | !ol] [$S] [b | h | l | I] y
Modifier | Interpretation |
---|---|
Default Functionality | The data block is received as raw binary data. |
* (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. |
!ob | Data is expected to be in standard IEEE 488.2 (big endian) format. This is the default behavior if neither !ob nor !ol is present. Byte-swapping is automatically performed on all elements in the array argument. |
!ol | Data is expected to be in little endian format. |
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.
|
HRESULT hr = S_OK; short rgData[100]; // Raw binary block of 100 16-bit words, big endian byte ordering hr = io.Scanf(_T("%100hy"), rgData); // Raw binary block of 100 16-bit words, little endian byte ordering // Number of elements specified as a variable int nCount = 100; hr = io.Scanf(_T("%#!olhy"), &nCount, rgData); // nCount updated with actual number of 16-bit words read SAFEARRAY* psa = NULL; // Raw binary block of 100 32-bit long words. Argument is a SAFEARRAY. // No field width is needed as Scanf allocates the SAFEARRAY memory hr = io.Scanf(_T("%$Sly"), &psa); // ... use SAFEARRAY result // IMPORTANT: SAFEARRAY must be destroyed hr = ::SafeArrayDestory(psa);