Difference between revisions of "IDE directives"

From Free Pascal wiki
Jump to navigationJump to search
m (Text replace - "Delphi>" to "syntaxhighlight>")
Line 3: Line 3:
 
IDE directives are similar to compiler directives as they are special comments in the source. They use the curly brackets and the percentage sign. For example:
 
IDE directives are similar to compiler directives as they are special comments in the source. They use the curly brackets and the percentage sign. For example:
  
<Delphi>
+
<syntaxhighlight>
 
{%H-}
 
{%H-}
</Delphi>
+
</syntaxhighlight>
  
 
For the compiler they are simple comments and ignored. The IDE uses these directives to store source specific information independent of project and session.
 
For the compiler they are simple comments and ignored. The IDE uses these directives to store source specific information independent of project and session.
Line 13: Line 13:
 
To hide one single hint, note or warning you can use the following IDE directive:
 
To hide one single hint, note or warning you can use the following IDE directive:
  
<Delphi>
+
<syntaxhighlight>
 
procedure DoSomething({%H-}NotUsed: char);
 
procedure DoSomething({%H-}NotUsed: char);
 
begin
 
begin
  
 
end;
 
end;
</Delphi>
+
</syntaxhighlight>
  
 
Hint: You can right click on a hint in the message window and click on "hide message via directive" to insert the directive automatically.
 
Hint: You can right click on a hint in the message window and click on "hide message via directive" to insert the directive automatically.
Line 28: Line 28:
 
You can specify what encoding the IDE should use for a source file by adding a BOM or an encoding directive at the very start of a source file:
 
You can specify what encoding the IDE should use for a source file by adding a BOM or an encoding directive at the very start of a source file:
  
<Delphi>
+
<syntaxhighlight>
 
{%encoding CP1250}
 
{%encoding CP1250}
</Delphi>
+
</syntaxhighlight>
  
 
See the unit lcl/lconvencoding.pas for all possible values.
 
See the unit lcl/lconvencoding.pas for all possible values.

Revision as of 00:49, 25 March 2012

Overview

IDE directives are similar to compiler directives as they are special comments in the source. They use the curly brackets and the percentage sign. For example:

{%H-}

For the compiler they are simple comments and ignored. The IDE uses these directives to store source specific information independent of project and session.

Hide one hint, note or warning

To hide one single hint, note or warning you can use the following IDE directive:

procedure DoSomething({%H-}NotUsed: char);
begin

end;

Hint: You can right click on a hint in the message window and click on "hide message via directive" to insert the directive automatically.

This feature exists since 0.9.29.

File encoding

You can specify what encoding the IDE should use for a source file by adding a BOM or an encoding directive at the very start of a source file:

{%encoding CP1250}

See the unit lcl/lconvencoding.pas for all possible values.

Run/Build file

See Configure Build File.

Reading / finding IDE directives

The codetools unit basiccodetools contains several functions for reading IDE directives:

  • FindNextIDEDirective