=?iso-8859-1?Q?Miguel_A_P=E9rez_E?= wrote:
Hello, please forgiveme if this is a trivial question.
No, but did you have to post this 3 times with 3 different subjects???
I have an integer variable and I am looking for the easiest way to convert it to an ascii or hexa form.
sNumber := HexaToAscii( '30414439');
Then sNumber results in '0AD9'
But the string '30414439' is in hexa and it corresponds with the decimal number 809583673.
What function will allow me to obtain that hexa string or the ascii string from the integer number?
I don't quite understand which way you want to convert. `HexaToAscii' doesn't make much sense to me since hex (or any other base) is about represening numbers as sequences of digits (usually in ASCII) while the internal representation of integers is always in base 2 (which is invisible to the programmer, except for bit operations).
So, there are two possibilities:
Hex to integer:
ReadStr ('16#' + '30414439', i);
Integer to hex:
No built-in routine available yet. You can use a self-written solution like Maurice's (but it should use a repeat loop rather than a while loop, otherwise it will produce an emtpy string for i = 0).
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/ GPC To-Do list, latest features, fixed bugs: http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html