Page 1 of 1
[Implemented] Val() and hex
Posted: Thu May 09, 2002 8:39 pm
by BackupUser
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.
Posted: Thu May 09, 2002 10:14 pm
by BackupUser
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$).
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
Posted: Thu May 09, 2002 10:23 pm
by BackupUser
Restored from previous forum. Originally posted by freak.
Thanks PB! Works fine.
Timo
--
A debugged program is one for which you have not yet found the conditions that make it fail.
Posted: Thu May 09, 2002 10:36 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
> 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$).
There's a command in the StringLibraryEx 3rd party lib called exactly that
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.10)
Posted: Thu May 09, 2002 10:55 pm
by BackupUser
Restored from previous forum. Originally posted by freak.
Well, you're right. I should have looked at Paul's site before posting this
--
A debugged program is one for which you have not yet found the conditions that make it fail.