Description |
The $Hints compiler directive determines whether Delphi shows compilation hints or not.
Hints are very useful for pointing out potential or real code problems. You should always have hints on, and ideally always change your code so that there are no compilation hints. It is all too easy to see hints as irritations, but they are there for a real purpose.
|
|
Notes |
The default value is $Hints On
$Hints should be set only once in your code.
|
|
Related commands |
$Warnings |
|
Determines whether Delphi shows compilation warnings |
|
|
|
Example code : Give hints for failing to use a variable, and to use an assigned value |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
i,j : Integer;
begin // Set hints on
{$Hints On}
// Set i to a known value
i := 234;
end; end.
|
Hide full unit code |
Hints displayed :
[Hint] Unit1.pas(40): Value assigned to 'i' never used
[Hint] Unit1.pas(34): Variable 'j' is declared but never used in 'TForm1.FormCreate'
|
|
Example code : No hints for failing to use a variable, and to use an assigned value |
var
i,j : Integer;
begin // Set hints off
{$Hints Off}
// Set i to a known value
i := 234;
end;
|
Show full unit code |
Code gives no hints
|
|