Click or drag to resize

QueryNumber

Performs a write and read of a numeric result through as a single operation.

virtual HRESULT QueryNumber(const CString& strCommand, double* pResult, bool bFlush = true, long lTimeout = CUR_TIMEOUT)  abstract;

virtual HRESULT QueryNumber(const CString& strCommand, float* pResult, bool bFlush = true, long lTimeout = CUR_TIMEOUT) abstract;

virtual HRESULT QueryNumber(const CString& strCommand, long* pResult, bool bFlush = true, long lTimeout = CUR_TIMEOUT) abstract;

virtual HRESULT QueryNumber(const CString& strCommand, short* pResult, bool bFlush = true, long lTimeout = CUR_TIMEOUT) abstract;

virtual HRESULT QueryNumber(const CString& strCommand, BYTE* pResult, bool bFlush = true, long lTimeout = CUR_TIMEOUT) abstract;
Parameters
strCommand

[in] Command string to send to the device.

pResult

[out] Numeric response read from the device.

bFlush

[in] true to flush the formatted I/O read buffer.

lTimeout

[in] I/O timeout value in milliseconds.

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

The QueryNumber function provides a mechanism of "send, then receive" typical to a device command sequences. In this manner, the response generated from the command can be read immediately. The device is not polled for errors after the write portion of the sequence.

The QueryNumber function performs a WriteStringNoPoll operation followed immediately by a ReadNumber operation.

If the device response could not be parsed into the type of number requested, this function returns an error.

For more precise control of the response formatting and conversion, use the Scanf function.

Example

The following example demonstrates use of the QueryNumber function.

C++
// CoAcme4321.cpp
STDMETHODIMP Acme4321::IAcme4321_get_TriggerCount(long* plCount)
{
  HRESULT hr = S_OK;

  hr = io.QueryNumber(_T("TRIG:COUNT?"), plCount);

  return hr;
}
See Also

Download a complete CHM version of this documentation here.