Little question

Blitz3D Forums/Blitz3D Programming/Little question

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.

I tought this was a challenge, so I came up with this quick-and-dirty solution for you (only works with lowercase, so if you make a function out of it, make it convert the string to lowercase first) :

N%=0
H$="e0ee"

for i=1 to len(h$)
	h_part$=Mid(h$,i%,1)
	select (h_part$)
		case "0"
			val=0
		case "1"
			val=1
		case "2"
			val=2
		case "3"
			val=3
		case "4"
			val=4
		case "5"
			val=5
		case "6"
			val=6
		case "7"
			val=7
		case "8"
			val=8
		case "9"
			val=9
		case "a"
			val=10
		case "b"
			val=11
		case "c"
			val=12
		case "d"
			val=13
		case "e"
			val=14
		case "f"
			val=15
	end select
	val2=16^(len(h)-i)*val
	; some debug info :
	;print (len(h)-i)+" "+val+" "+val2
	n=n+val2
next

print n