Enum to String conversion using label values.
str dtGetZeroValueReasonCode()
{
DictEnum dictEnum;
int valueIndex;
int enumId;
str labelId;
str reasonCode;
;
enumId = enumNum(rdZeroWeightReasonCode);
dictEnum = new DictEnum(enumId);
if (dictEnum)
{
for (valueIndex = 0 ; valueIndex < dictEnum.values(); valueIndex++)
{
labelId = dictEnum.index2LabelId(valueIndex);
reasonCode += strFmt('%1;',SysLabel::labelId2String(labelId) ? SysLabel::labelId2String(labelId) : dictEnum.index2Label(valueIndex));
}
}
// Remove the trailing ";" if it exist
if (reasonCode != "")
{
reasonCode = strDel(reasonCode,strLen(reasonCode),1);
}
return reasonCode;
}
retrieve enum name from string
zeroWeightReasonCodeStr = zeroWeightReasonCodeElement.innerText();
zeroWeightReasonCode = str2Enum(zeroWeightReasonCode, zeroWeightReasonCodeStr);
str dtGetZeroValueReasonCode()
{
DictEnum dictEnum;
int valueIndex;
int enumId;
str labelId;
str reasonCode;
;
enumId = enumNum(rdZeroWeightReasonCode);
dictEnum = new DictEnum(enumId);
if (dictEnum)
{
for (valueIndex = 0 ; valueIndex < dictEnum.values(); valueIndex++)
{
labelId = dictEnum.index2LabelId(valueIndex);
reasonCode += strFmt('%1;',SysLabel::labelId2String(labelId) ? SysLabel::labelId2String(labelId) : dictEnum.index2Label(valueIndex));
}
}
// Remove the trailing ";" if it exist
if (reasonCode != "")
{
reasonCode = strDel(reasonCode,strLen(reasonCode),1);
}
return reasonCode;
}
retrieve enum name from string
zeroWeightReasonCodeStr = zeroWeightReasonCodeElement.innerText();
zeroWeightReasonCode = str2Enum(zeroWeightReasonCode, zeroWeightReasonCodeStr);
No comments:
Post a Comment