Re: I suppose the idea of classes and inheritance is



On Thu, 12 Oct 2006 11:19:47 -0700, Jamie
<jamie_ka1lpa_not_valid_after_ka1lpa_@xxxxxxxxxxx> wrote:

<snip>

While the String is 'terminated' with #0, attempting to get at that
index produces a Range Error if Range Checking is turned on.

procedure TForm1.Button1Click(Sender: TObject);
Var
S :String;
C :Char;
begin
{$R+}
S := StringOfChar('a', 10);
C := S[ Length( S ) + 1 ];
ShowMessage( IntToStr( Ord(C) ) );

end;

procedure TForm1.Button1Click(Sender: TObject);
var
S:String;
X:Integer;
C:char;
begin
C:= #$FF;
S := 'Test';
X := 5;
C := S[X];
if C = #0 then Beep;
end;
the above test does not generate a range error.
test your findings first please.

You have not got Range Checking turned on
- either turn it on via Project/Options or use {$R+}
- then try running the code

IMO Range Checking should always be on by default, and only turned off
under very defined circumstances.


--
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5


.