Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get rid of a warning 1

Status
Not open for further replies.

pierrotsc

Programmer
Nov 25, 2007
358
0
0
US
I keep getting:
[DCC Warning] NoiseFilter.pas(6879): W1036 Variable 'number' might not have been initialized

Even if I add number:=0; to the procedure, I will still get the warning.

Anyway to get rid of this warning. I get 100 times because it is in 100 procedures of the same kind.

here's the code:
procedure TNoiseForm.edt001Exit(Sender: TObject);
var
Code: Integer;
number:float;
CurrEdit: textEdit;
begin
CurrEdit := Sender as textEdit;
if CurrEdit.Text <> '' then
begin
Val (CurrEdit.Text, Number, Code);
if Code <> 0 then
begin
CurrEdit.SetFocus;
MessageDlg ('The edit field number ' +
IntToStr (CurrEdit.Tag) +
' does not have a valid number',
mtError, [mbOK], 0);
end;
end;
if methodradiogroup.itemindex=1 then store[1]:=round(number)
else stored[1]:=number;
end;

Thanks.
 
If I am not mistaken, it is giving you the warning because you assign a value to Number inside of an [blue]If[/blue] statement.
So Delphi sees it as there is a chance that [blue]Number[/blue] will not be assigned if you do not go into the [blue]If[/blue] statement.

~
Chuck Norris is the reason Waldo is hiding.
 
I apologize, I did not offer up a way to remove the warning in the first reply.
To get rid of it, just assign a value to it before it is used.
[blue]Number := 0;[/blue] will do even. That way Delphi knows it was assigned for sure. I am not sure if there is another way to remove the warning, short of turning the warnings off altogether.

~
Chuck Norris is the reason Waldo is hiding.
 
Thanks, by adding the number:=0; it fixed it. I was sure i tried that before. I guess i placed the statement at the wrong place.

Again, thanks.
PO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top