[in] Enum value to be converted.
EnumToCommand
Converts an enum value into its corresponding instrument command.
Syntax
Section titled “Syntax”template <typename T>bool EnumToCommand(T enumVal, CString& strCommand) const;Parameters
Section titled “Parameters”enumVal
strCommand
[out] Command string associated with the specified enum value.
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 enum value to its associated command string.
For example, a developer may have associated the enum value Acme4321TriggerSourceExternal with the command string “EXT”. The EnumToCommand function can be used to help format a complete command string for setting, say, the trigger source.
It should be noted that directly calling EnumToCommand within a method or property implementation is rarely necessary. This is because the Printf function supports formatting enums as strings directly. (Indeed, the implementation of Printf calls EnumToCommand.)
Example
Section titled “Example”The following example demonstrates use of the EnumToCommand function.
HRESULT Acme4321::ConfigureTriggerSource(){ HRESULT hr = S_OK;
// Write, but don't flush since we need to add on the enum string hr = io.WriteString(_T("TRIG:SOUR "), false);
Acme4321TriggerSourceEnum eSource = Acme4321TriggerSourceExternal; CString strSource; if (EnumToCommand<Acme4321TriggerSourceEnum>(eSource, strSource)) { // Sends "EXT", assuming that we configured in the Enum Command Editor hr = io.WriteString(strSource); }
return hr;}