Example:
a$ = "$10"
debug Val(a$)
;would be cool if it returns 16 instead of 0
[Implemented] Val function to work with hexadecimal strings
[Implemented] Val function to work with hexadecimal strings
AMD 1.8 - 512mb - ATI All-In-Wonder Radeon 9000 pro - W2k Pro
BASIC programmers never die, they just return without gosub.
BASIC programmers never die, they just return without gosub.
Re: Val function to work with hexadecimal in strings
In the meantime, try this:
Code: Select all
Procedure hex2dec(h$)
h$=Trim(UCase(h$)) : If Left(h$,1)="$" : h$=Mid(h$,2,999) : EndIf
For r=1 To Len(h$)
d<<4 : a$=Mid(h$,r,1)
If Asc(a$)>60
d+Asc(a$)-55
Else
d+Asc(a$)-48
EndIf
Next
ProcedureReturn d
EndProcedure
a$="$10"
Debug hex2dec(a$)
Re: Val function to work with hexadecimal in strings
@Fred: Please make a native hex2dec command soon. Please. 

- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
maybe useful in the meantime:
http://www.purebasic.fr/english/viewtopic.php?p=229827
http://www.purebasic.fr/english/viewtopic.php?p=229827
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!
"
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!
