I'm migrating a software from Delphi 5 to Delphi XE. I've already corrected a lot of differences, and i can now compile my code.
The problem happening is that sometimes (in some places of the code), I'm getting the error "Range Check Error".
For exemple, in this code:
function CopyChar(Ori : string; var Des : Array of char) : Boolean;
var Msg : string;
Counter : integer;
SizeDes : integer;
begin
SizeDes:= SizeOf(Des);
for Counter:= 1 to SizeDes do begin
Des[Counter-1]:= ' ';
end;
Ori:= Trim(Ori);
Msg:= '';
SizeDes:= Min(Length(Ori),SizeDes);
for Counter:= 1 to SizeDes do begin
Des[Counter-1]:= char(Ori[Counter]);
end;
CopyChar:= True;
end;
I get the error at runtime when passing by the line Des[Counter-1] := ' '; The error occurr not at the first time it passes through the loop, but after lot of times.
I've tried to disable Rance Checking ($R) but it does nos solves my problem. I've also tried to change the type of "Counter" to Cardinal and LongWord, with no success
I would be glad for any helpful idea!
Thanks.