How about this?
procedure Samuel([arguments]);
var
bob: Integer;
begin
...
if [condition1] then
bob := 1
else if [condition2] then
bob := 2
else if [condition3] then
bob := 3
else
begin
raise Exception.Create('error message');
bob := 0; // added this line to get rid of warning
end;
jim := bob + 10;
...
end;
Leigh
http://www.salenz.com
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Allan, Samuel
Sent: Tuesday, June 01, 2004 11:07 AM
To: NZ Borland Developers Group - Delphi List
Subject: RE: [DUG] Weird Delphi Warning
I've got another one that I found funny:
procedure Samuel([arguments]);
var
bob: Integer;
begin
...
if [condition1] then
bob := 1
else if [condition2] then
bob := 2
else if [condition3] then
bob := 3
else
raise Exception.Create('error message');
jim := bob + 10;
...
end;
gives the warning "Variable 'bob' might not have been initialized" on
the line "jim := bob + 10". Which is true, even though if bob has no
value then the exception will prevent that line of code from being run.
But, if you change the code to:
procedure Samuel([arguments]);
var
bob: Integer;
begin
...
bob := 0; // added this line to get rid of warning
if [condition1] then
bob := 1
else if [condition2] then
bob := 2
else if [condition3] then
bob := 3
else
raise Exception.Create('error message');
jim := bob + 10;
...
end;
then you get a hint "Value assigned to 'bob' never used".
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi