![]() | WriteList |
Sends a delimited list of values to a device.
virtual HRESULT WriteList(double* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(float* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(long* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(short* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(BYTE* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(SAFEARRAY* pValues, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(const CString& strCommand, double* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(const CString& strCommand, float* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(const CString& strCommand, long* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(const CString& strCommand, short* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(const CString& strCommand, BYTE* pValues, long lLength, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override; virtual HRESULT WriteList(const CString& strCommand, SAFEARRAY* pValues, const CString& strListSeparator = _T(","), bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
[in] Command to send to the device before sending the list.
[in] Array of numeric values to send to the device.
[in] Number of elements (not bytes) to send to the device. If the input is a SAFEARRAY, then all elements of the SAFEARRAY are sent.
[in] If true, the formatted I/O write buffer is flushed to the device.
[out] Characters to use as separators between elements in the list.
[in] I/O timeout value in milliseconds.
Returns S_OK if successful, otherwise a failure HRESULT.
The WriteList function formats each number in the pValues input array as a string according to the default format settings specified in the I/O Page of the Driver Settings Editor. Each element is separated by the strListSeparator. 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.
The following example demonstrates use of the WriteList function.
// CoAcme4321.cpp STDMETHODIMP Acme4321::IAcme4321_Configure(SAFEARRAY* psaData) { HRESULT hr = S_OK; // Sends comma-separated list of elements in psaData hr = io.WriteList(psaData); return hr; }