[in] Command to send to the device before sending the value.
WriteNumber
Formats a number as a string and sends it to a device.
Syntax
Section titled “Syntax”virtual HRESULT WriteNumber(double value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteNumber(float value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteNumber(long value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteNumber(short value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteNumber(BYTE value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteNumber(const CString& strCommand, double value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteNumber(const CString& strCommand, float value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteNumber(const CString& strCommand, long value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteNumber(const CString& strCommand, short value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteNumber(const CString& strCommand, BYTE value, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;Parameters
Section titled “Parameters”strCommand
value
[in] Number to format and send to the device.
bFlush
[in] If true, the formatted I/O write buffer is flushed to the device.
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 WriteNumber function formats a number as a string according to the default format settings specified in the I/O Page of the Driver Settings Editor. The resulting string is sent to the formatted I/O write buffer.
For more precise control of the numeric formatting (or to simply override the defaults), use the Printf function.
If the bFlush parameter is true, then the contents of the I/O write buffer are flushed to the device. If bFlush is false, then the data is queued in the write buffer until the buffer is full or a subsequent operation forces a flush. Queueing data in this fashion can improve I/O performance by reducing the number of I/O roundtrips to the device.
Example
Section titled “Example”The following example demonstrates use of the WriteNumber function.
STDMETHODIMP Acme4321::IAcme4321_Configure(long lCount, double dRange, double dResolution){ HRESULT hr = S_OK;
// Queue up commands in the write buffer hr = io.WriteNumberNoPoll(lCount, false); hr = io.WriteNumberNoPoll(dRange, false);
// Send string and flush buffer to device hr = io.WriteNumber(dResolution);
return hr;}