## PrintPreview and Range Checking

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

### PrintPreview and Range Checking

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?
sebybar
Member

Posts: 2
Joined: November 18th, 2003, 7:00 pm

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)
Johnny_Bit
VIP Member

Posts: 455
Joined: June 15th, 2003, 9:56 am

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)
sebybar
Member

Posts: 2
Joined: November 18th, 2003, 7:00 pm

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.

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

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.

Kambiz