Click or drag to resize

QueryfWithTimeout

Performs a formatted write and read through as a single operation.

virtual HRESULT QueryfWithTimeout(const CString strWriteFormat, const CString strReadFormat, long lTimeout [, argument] ...) abstract;
Parameters
strWriteFormat

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

strReadFormat

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

argument

[in] Optional arguments interpreted by the write and read format strings.

lTimeout

[in] I/O timeout value in milliseconds.

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

The QueryfWithTimeout function behaves identically to the Queryf function except that an I/O timeout parameter is supplied. The lTimeout parameter allows the I/O timeout to be temporarily changed to the specified value for the duration of the QueryfWithTimeout function call. The timeout is returned to its previous value after QueryfWithTimeout returns.

Example

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

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

  // Start a measurement that will generate a lot of data and   {
  // read an IEEE 488.2 binary block as the response.
  // Needs up to 10 seconds to complete
  SAFEARRAY* psaData = NULL;
  hr = io.QueryfWithTimeout(_T("MEAS:DATA?"), _T("%$Sb"), 10000, &psaData);

    // I/O timeout automatically changed back to previous value before ScanfWithTimeout call

  return hr;
}
See Also

Download a complete CHM version of this documentation here.