Re: converting hex to decimal...

new topic     » goto parent     » topic index » view thread      » older message » newer message

> The hex numbers are strung together in a file like:
> 1F0AB420FF1C
> which seems impossible to decode, but it's number every 2 digits, eg:
> [1F] [0A] [B4] [20] [FF] [1C]
> is the same sequence broken into number lots.
>
> I can do that okay, but i am having trouble converting #FF to 255 etc
> and 255 to #FF

        Ok, here it comes...

--code begins here --------- actually it begins at the next line ----

        include get.e           -- for value ()

        function get_hex_value ( sequence hex_string )
        sequence ret
                ret = value ("#" & hex_string)
                if ret[1] = GET_SUCCES then
                        return ret[2]
                else
                        puts(1,"BAD HEX VALUE !!\n\n")
                        abort(1)
                end if
        end function
------------------------------ code ended line above -------

        Just include the above in your program and all get_hex_value() to
get the heximal value. Exemple:

         ? get_hex_value("FF")

        Will write 255 to the screen...

        Your welcome...

Ralf Nieuwenhuijsen
nieuwen at xs4all.nl

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu