[out] Number read from the device.
ReadNumber
Reads numeric data from a device.
Syntax
Section titled “Syntax”virtual HRESULT ReadNumber(double* pValue, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT ReadNumber(float* pValue, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT ReadNumber(long* pValue, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT ReadNumber(short* pValue, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT ReadNumber(BYTE* pValue, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;Parameters
Section titled “Parameters”pValue
bFlush
[in] If true, the formatted I/O read buffer is flushed.
lTimeout
[in] I/O timeout value in milliseconds.
Return value
Section titled “Return value”Returns S_OK if successful, otherwise a failure HRESULT.
Remarks
Section titled “Remarks”The ReadNumber function reads string data from the formatted I/O read buffer and converts it to a number. Integers are converted in the base specified.
If the bFlush parameter is true, then the contents of the I/O read buffer are flushed. Flushing the read buffer ensures no unintentional data remains in the buffer for subsequent reads.
If the device response string cannot be converted into the numeric type requested, this function returns an error.
For more precise control of the response formatting and conversion, use the Scanf function.
Example
Section titled “Example”The following example demonstrates use of the ReadNumber function.
STDMETHODIMP Acme4321::IAcme4321_get_Count(long* plCount){ HRESULT hr = S_OK;
hr = io.ReadNumber(plCount);
return hr;}