I've just finished my Hex2Dec() function.
- My function is case-in-sensitive, you can give it any string you want. It examines the hex-string from behind and stops, when detecting an invalid character. So you can even give my function strings like "$123" or "0xFF". It's able to work with very high hex-numbers which are returned by HexQ().
Code: Select all
Procedure.q Hex2Dec(Hex.s)
Protected result.q, n, temp, pow.q=1
hex=UCase(hex)
For n=MemoryStringLength(@Hex)-1 To 0 Step -1
temp=PeekC(@Hex+n*SizeOf(Character))-48
If temp >= 17 And temp <= 22
temp-7
ElseIf temp < 0 Or temp > 9
Break
EndIf
result+temp*pow
pow*16
Next
ProcedureReturn result
EndProcedure
Debug $Affe123
Debug Hex2Dec("$Affe123")