Compiled but untested.
// Converts the 0x?? hex string from MetamagicType and TargetType strings
// to usable integers.
int HexStringToInt (string sHex)
{
string HexDigits = "0123456789abcdef";
sHex = GetStringLowerCase (sHex);
int nCount = GetStringLength(sHex);
int nDigitPosValue = 1;
int nValue =0;
int nDigitValue;
while (nCount)
{
nCount--;
nDigitValue = FindSubString (HexDigits,GetSubString(sHex,nCount,1));
if (nDigitValue != -1)
{
nValue += nDigitValue * nDigitPosValue;
nDigitPosValue *= 16;
}
else break; // We hit an invalid character, Most likely the x.
}
return nValue;
}
EDIT: spotted my rookie mistake even without testing. Hopefully it is good now.
Modifié par Lightfoot8, 06 mai 2012 - 05:20 .