PROCEDURE hex_to_dec !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! TPU procedure to provide a HEX to DECIMAL conversion facility ! for unsigned integers for EVE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LOCAL the_num , a_digit , d_index , hex_str , spa_str , dec_str , dig_str , atf_str ; if ( eve$prompt_string ( "" , hex_str , "Enter hex number: " , "No number entered" ) ) then the_num := 0 ; d_index := 1 ; spa_str := ' ' ; atf_str := 'abcdefABCDEF' ; dec_str := '0123456789' ; dig_str := dec_str + atf_str ; loop ! DISCARD WHITE-SPACE a_digit := substr ( hex_str , d_index , 1 ) ; exitif ( index ( spa_str , a_digit ) = 0 ) ; d_index := d_index + 1 ; endloop ; loop ! PROCESS DIGITS UNTIL END OR WHITESPACE OR ERROR exitif ( d_index > length ( hex_str ) ) ; a_digit := substr ( hex_str , d_index , 1 ) ; exitif ( index ( spa_str , a_digit ) <> 0 ) ; if ( index ( dig_str , a_digit ) = 0 ) then message ( 'Illegal character ' + a_digit + ' in string ' + hex_str + '; current value: ' + ascii ( the_num ) ) ; return ; else if ( index ( dec_str , a_digit ) <> 0 ) then the_num := 16 * the_num + int ( a_digit ) ; else if ( ( a_digit = 'a' ) or ( a_digit = 'A' ) ) then the_num := 16 * the_num + 10 ; else if ( ( a_digit = 'b' ) or ( a_digit = 'B' ) ) then the_num := 16 * the_num + 11 ; else if ( ( a_digit = 'c' ) or ( a_digit = 'C' ) ) then the_num := 16 * the_num + 12 ; else if ( ( a_digit = 'd' ) or ( a_digit = 'D' ) ) then the_num := 16 * the_num + 13 ; else if ( ( a_digit = 'e' ) or ( a_digit = 'E' ) ) then the_num := 16 * the_num + 14 ; else if ( ( a_digit = 'f' ) or ( a_digit = 'F' ) ) then the_num := 16 * the_num + 15 ; endif ; endif ; endif ; endif ; endif ; endif ; endif ; endif ; d_index := d_index + 1 ; endloop ; message ( 'HEX ( ' + hex_str + ' ) == ' + 'DECIMAL ( ' + str ( the_num ) + ' )' ) ; endif ; return ; ENDPROCEDURE ;