Click or drag to resize

Printf

Sends formatted output to a device.

virtual HRESULT Printf(const CString strFormat [, argument] ...) abstract;
Parameters
strFormat

[in] String describing the format for arguments. See the topic I/O Format Specifiers for Write Operations for details.

argument

[in] Optional arguments interpreted by the format string.

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

The Printf function formats and sends a series of characters to a device. Any arguments passed to Printf are converted and formatted and the resulting string is sent to the formatted I/O buffer.

If the strFormat parameter ends in a newline character (\n), then the contents of the formatted I/O buffer are flushed to the device and an END indicator is sent with the last byte (the newline character).

If the I/O buffer is flushed, the instrument is polled for errors.

Example

The following example demonstrates use of the Printf function. Note that the topic I/O Format Specifiers for Write Operations has many more examples of format strings that can be used with Printf.

C++
// CoAcme4321.cpp
STDMETHODIMP Acme4321::IAcme4321_Configure(double Range, double Resolution)
{
  HRESULT hr = S_OK;

  // Send command to device, flush I/O buffer
  hr = io.Printf(_T("SENS:MEAS %f, %6.2e"), Range, Resolution);

  return hr;
}
See Also

Other Resources

Download a complete CHM version of this documentation here.