November 2019
Beginner to intermediate
674 pages
15h
English
The last compiler option I want to discuss, Range checking, tells the compiler whether to check indexes to arrays and strings. In other words, it will check if in expression such as s[idx+1], idx+1 represents a valid index.
You can turn range checking on and off with compiler directives {$RANGECHECKS ON} and {RANGECHECKS OFF} (or {$R+} and {$R-}).
Let's take a look at an example. In the method shown here, the second for loop accesses element arr[101] without any error, although the maximum array element is arr[100]. The third for loop, however, will raise an ERangeCheck exception when accessing arr[101]:
procedure TfrmCompilerOptions.btnRangeErrorClick(Sender: TObject);var arr: array [1..100] of Integer; i: Integer;begin for ...
Read now
Unlock full access