Hexidecimal to decimal

There are many ways to convert a hex string into decimal number. I am presenting two different versions here.

Function HexToInt Global String sNum Returns Integer // Version 1
	Function_Return (Integer("$"+sNum))
End_Function

Function HexToInt Global String sNum Returns Integer // Version 2
	Integer iLength iDigit iNum iPower
	Move (Length(sNum)) to iLength
	Move 1 to iPower
	Move 0 to iNum
	While (iLength>0)
		Move (Ascii(Mid(sNum,1,iLength))) to iDigit
		Subtract (If(iDigit>57,55,48)) From iDigit
		Add (iDigit*iPower) to iNum
		Move (iPower*16) to iPower
		Decrement iLength
	Loop
	Function_Return iNum
End_Function // HexToInt
Free Web Hosting