Click or drag to resize

WriteNumber

Formats a number as a string and sends it to a device.

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
strCommand

[in] Command to send to the device before sending the value.

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

Returns S_OK if successful, otherwise a failure HRESULT.

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

The following example demonstrates use of the WriteNumber function.

C++
// CoAcme4321.cpp
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;
}
See Also

Download a complete CHM version of this documentation here.