Page 1 of 1

PrintPreview and Range Checking

PostPosted: November 18th, 2003, 7:06 pm
by sebybar
I found that the PrintPreview Component raise a runtime error if you compile it with the range checking option.
Try to compile the General Demo project and move the scroll bar.
Is it dangerous for my application?

PostPosted: November 19th, 2003, 7:44 am
by Johnny_Bit
Range Checking is only for debuging matters, it slows down whole application. If you're writing good code, range checking could be allways off.

This is dangerous if your application is more than tinny and yo're trying to run it on slow computer (e.g. lest than 333MHz)

PostPosted: November 19th, 2003, 12:30 pm
by sebybar
Yes, I know that.
But I meant another thing:
If a range checking error is raised, it means that something is going wrong with the procedure. Is it a bug? Is it a serious bug?


Johnny_Bit wrote:Range Checking is only for debuging matters, it slows down whole application. If you're writing good code, range checking could be allways off.

This is dangerous if your application is more than tinny and yo're trying to run it on slow computer (e.g. lest than 333MHz)

PostPosted: November 19th, 2003, 2:02 pm
by Kambiz
It's not always because of an out of range index reference. Sometimes the range check code (added by compiler) makes a mistake, specially on parameters of API calls.

PostPosted: November 20th, 2003, 5:01 pm
by Kambiz
There's something wrong in the following code?

Code: Select all
type
  PByteArray = ^TByteArray;
  TByteArray = array[0..0] of Byte;
var
  pba: PByteArray;
  I: Integer;
begin
  GetMem(pba, 100);
  try
    for I := 0 to 99 do
      pba[I] := I;
    // The rest of code
  finally
    FreeMem(pba);
  end;
end.

Absolutely not! However, when range checking is on, a run-time error will terminate the program.