DEC(<C hex string>)
Converts a hexadecimal number (base 16) to a decimal number (base 10).
Returns <expN> decimal value of <hex string>.
Returns zero if <hex string> contains an invalid character.
DEC( "FF" ) returns 255
DEC( "4F" ) returns 79
DEC( "3" ) returns 3
DEC( "C8" ) returns 200
DO WHILE .T.
ACCEPT "Enter a hex number:" TO m_hex
DO CASE
CASE [] = m_hex
EXIT
CASE DEC( m_hex ) = 0 .AND. VAL(m_hex) <> 0
? "Error -- invalid character in hex string."
OTHERWISE
? "Result: " + LTRIM(STR( DEC(m_hex) ))
ENDCASE
ENDDO
Placed in the Public Domain by Tom Rettig Assoc.