Range Check Error and Delphi 7.0

After spending a week checking and fixing my program for memory leaks through FastMM4, I finally tested my program on another PC. Now I get a "Range Check Error". I spent hours researching online about this, but none of them seem to give me what I am looking for. My program was run with the Runtime Error Range Check parameter. So, I know why I get the error message, but I need to know exactly why the error occurs.

The program was compiled on XP with Delphi 7.0. The test PC is Windows 7. As soon as it starts, my program starts communicating via the serial port, and then the “Range check error” message box appears. When I stop serial communication, there are no "Range Check Error" checkboxes. What does this mean and how can I solve it? I am looking for a simple strategy. I know that I could spend several days in a row.

"Range check error" caused by incorrect value assignment or access to an inaccessible array index. I'm right?

+5
source share
2 answers

Your understanding of range check errors is correct. They arise when accessing an array outside its boundaries. For instance:

type
  TFixedArray = array [0..41] of Integer;
var
  a: TFixedArray;
begin
  a[42] := 1+2;//!! this is a range check error !!
end;

:

var
  a: array of Integer;
begin
  SetLength(a, 666);
  a[665] := 12;//this is fine
  a[666] := 42;//!! this is a range check error !!
end;

, .

, , . , madExcept - .


UPDATE

Ken, , :

{$ R +} .

+8

" ", , " " scenerio , : , , , 16- ( ) , , , . , [ , " ".], .

+1

All Articles