Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-01

Convert error hex string to cardinal....

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I have encountered a conversion error using FPC 2.4.2 with Lazarus 0.9.29 as follows:

var
  t: Int64;
  v: string;
begin
  ...
  t := StrToInt('$' + v);

This gives an exception "invalid integer". At this moment v is '577B4D58A51A0EE', which combined with the $ sign makes it a valid hex Int64 as far as I can see.
I have used constructs like this many times in Delphi without problems.

So what have I missed in FPC?

I am reading and converting GPG key ID:s, which are 64 bit integers expressed as 16 char hex code.

Bo Berglund Developer in Sweden

Reply by email

Vincent Snijders
to Bo Berglund

2011/1/17 Bo Berglund :

Show quoted text 13 lines
I have encountered a conversion error using FPC 2.4.2 with Lazarus 0.9.29 as follows: var  t: Int64;  v: string; begin  ...  t := StrToInt('$' + v); This gives an exception "invalid integer". At this moment v is '577B4D58A51A0EE', which combined with the $ sign makes it a valid hex Int64 as far as I can see.

For Int64 use StrToInt64:
http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/strtoint64.html

Vincent

Reply by email

Bo Berglund
to Vincent Snijders
Vincent Snijders wrote 18 lines
2011/1/17 Bo Berglund : > I have encountered a conversion error using FPC 2.4.2 with Lazarus > 0.9.29 as follows: > > var >  t: Int64; >  v: string; > begin >  ... >  t := StrToInt('$' + v); > > This gives an exception "invalid integer". At this moment v is > '577B4D58A51A0EE', which combined with the $ sign makes it a valid hex > Int64 as far as I can see. For Int64 use StrToInt64: http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/strtoint64.html

Thanks for the quick solution! :-)

Bo Berglund Developer in Sweden

Reply by email