Restored from previous forum. Originally posted by freak.
Hi,
It would be nice, if Val() could also convert strings like "$FF", or "%11011"
to numbers.
Or what about adding something like ValHex(), and ValBin()
Timo
--
A debugged program is one for which you have not yet found the conditions that make it fail.
[Implemented] Val() and hex
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> Or what about adding something like ValHex(), and ValBin()
That would be handy. In the meantime, if you need hex, try this... call it
like so: dec=hex2dec(hex$).
PB - Registered PureBasic Coder
Edited by - PB on 09 May 2002 23:20:41
> Or what about adding something like ValHex(), and ValBin()
That would be handy. In the meantime, if you need hex, try this... call it
like so: dec=hex2dec(hex$).
Code: Select all
Procedure.l hex2dec(h$)
; h$ can be 0-FFFFFFF.
h$=UCase(h$)
For r=1 To Len(h$)
d60
d+Asc(a$)-55
Else
d+Asc(a$)-48
EndIf
Next
ProcedureReturn d
EndProcedure
PB - Registered PureBasic Coder
Edited by - PB on 09 May 2002 23:20:41
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.10)
There's a command in the StringLibraryEx 3rd party lib called exactly that> Or what about adding something like ValHex(), and ValBin()
That would be handy. In the meantime, if you need hex, try this... call it
like so: dec=hex2dec(hex$).

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.10)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm