Board index » delphi » Convert String to Hex

Convert String to Hex

Quote

>Hi,
>how can I convert a String like this:
>     '1E'
>Into an Integer?

TP uses a $ to signify hexadecimal, so you're string should be '$1E'

So to get your string into an integer, just use something like this:

val( '$'+string, num, code);

--
WW (wonderw...@aol.com)

 

Re:Convert String to Hex


Hi,
how can I convert a String like this:
     '1E'
Into an Integer?

VAL does not work, cause it dosen't recognize the letters as numbers...

Thanks

--Torsten

Re:Convert String to Hex


Quote
stremlau wrote:

> Hi,
> how can I convert a String like this:
>      '1E'
> Into an Integer?

> VAL does not work, cause it dosen't recognize the letters as numbers...

I am not sure with newer versions, but old TP could convert
the hex number with a preceding '$', like
  Val('$'+Num,I,C);

If not, look for "RadixVal" or "ValRadix" (Sorry, I forgot
the name) in the math chapter of the TP-links:
http://www.geocities.com/SiliconValley/2926/tpf.html

:-) Franz Glaser

Re:Convert String to Hex


In article <77r78g$gl...@black.news.nacamar.net>,
Quote
stremlau <strem...@dialup.nacamar.de> wrote:

:Hi,
:how can I convert a String like this:
:     '1E'
:Into an Integer?
:VAL does not work, cause it dosen't recognize the letters as numbers...

That's not quite so:

var x : word;
    k : integer;
begin
  Val('$1E', x, k);
  writeln (x);
end.

For more see
 42) How do I convert a decimal word into a hexadecimal string, etc?

 158763 Dec 20 1998 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
 tsfaqp.zip Common Turbo Pascal Questions and Timo's answers, linked

   All the best, Timo

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/>  ; FIN-65101,  Finland

Spam foiling in effect.  My email filter autoresponder will return a
required email password to users not yet in the privileges database.
Advice on spam foiling at http://www.uwasa.fi/~ts/info/spamfoil.html

Re:Convert String to Hex


if you put a dollar-sign "$" in front of the string
val will recognize the string as integer

Other Threads