Click or drag to resize

EnumFromResponse

Converts an instrument response string to its corresponding enum value.

template <typename T>
bool EnumFromResponse(const CString& strResponse, T& enumVal) const;
Parameters
strResponse

[in] Response string to convert to an enum value.

enumVal

[out] Enum value converted from the specified response string.

Return Value

Returns true if the conversion was successful, otherwise false.

Remarks

The Instrument Command Editor allows the developer to associate enum values with command strings that can be sent to an instruments. This function converts an instrument response string to its associated enum value.

For example, a developer may have associated the enum value Acme4321TriggerSourceExternal with the response string "EXT". The EnumFromResponse function can be used to convert a string response "EXT" into the enum value Acme4321TriggerSourceExternal.

It should be noted that directly calling EnumFromResponse within a method or property implementation is rarely necessary. This is because the Scanf function supports scanning strings as enums directly. (Indeed, the implementation of Scanf calls EnumFromResponse.)

Example

The following example demonstrates use of the EnumFromResponse function.

C++
// CoAcme4321.cpp
HRESULT Acme4321::get_TriggerSource(Acme4321TriggerSourceEnum* peSource)
{
  HRESULT hr = S_OK;

  CString strResponse;
  hr = io.QueryString(_T("TRIG:SOUR?"), strResponse);

  Acme4321TriggerSourceEnum eSource;
  if (EnumFromResponse<Acme4321TriggerSourceEnum>(strResponse, eSource)
  {
    *peSource = eSource;
  }

  return hr;
}
See Also

Download a complete CHM version of this documentation here.