[in] Response string to convert to an enum value.
EnumFromResponse
Converts an instrument response string to its corresponding enum value.
Syntax
Section titled “Syntax”template <typename T>bool EnumFromResponse(const CString& strResponse, T& enumVal) const;Parameters
Section titled “Parameters”strResponse
enumVal
[out] Enum value converted from the specified response string.
Return value
Section titled “Return value”Returns true if the conversion was successful, otherwise false.
Remarks
Section titled “Remarks”The Instrument Command Editor allows the developer to associate enum values with command strings that can be sent to an instrument. 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
Section titled “Example”The following example demonstrates use of the EnumFromResponse function.
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;}