RunErr

Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

RunErr

 · 
Posted: 04.09.2014 - 15:03  ·  #1
RunErr for w := StrToInt('1234567') is false, and RunErr for w := StrToInt('-1') is false when w is word. Is this correct behavior? Do I have to make much more checking then originally thought?

Code
var
  s: string[10];
  w: word;
  b: boolean;
begin
  s := '123';
  w := StrToInt(s); // $007B
  b := RunErr;      // false (expected result)

  s := '1234567';
  w := StrToInt(s); // $D687    (conversion to long is $12D678)
  b := RunErr;      // false    (unexpected result) <<<<<<<<<<

  s := ' 1234';
  w := StrToInt(s); // $0000
  b := RunErr;      // true     (expected result)

  s := '-1';
  w := StrToInt(s); // $FFFF
  b := RunErr;      // false    (unexpected result) <<<<<<<<<<
end;
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   32   46 · Page-Gen-Time: 0.023874s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI