HexToInt?

BlitzMax Forums/BlitzMax Programming/HexToInt?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You need to kill any prefix to make it bullet proof:
Print HexToInt("#FF")
Print HexToInt("0x837F")
Print HexToInt("$ABC")

Function HexToInt( HexStr:String )
	Local n
	HexStr = HexStr.Trim().Replace("#","").Replace("$","").Replace("0x","").ToUpper()
	For Local d:Byte = 0 Until HexStr.length
		If HexStr[d]>64 And HexStr[d]<77 Then n = (n Shl 4) + HexStr[d]-55 ElseIf HexStr[d]>47 And HexStr[d]<58 Then n = (n Shl 4) + HexStr[d]-48 Else Return n
	Next
	Return n 
End Function
And For bla:byte = EachIn StringHere doesn't work for me either. I get the same error as BotBuilder.