Difference between revisions of "IDE directives"

From Free Pascal wiki
Jump to navigationJump to search
Line 11: Line 11:
 
=Hide one hint, note or warning=
 
=Hide one hint, note or warning=
  
To hide one single hint, note or warning you can use the following IDE directive:
+
To hide a single hint, note or warning you use the following IDE directive:
  
 
<syntaxhighlight>
 
<syntaxhighlight>
Line 20: Line 20:
 
</syntaxhighlight>
 
</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.
+
Note: You can right click on a hint in the message window and choose the context menu option "hide message via directive" to insert the directive automatically.
  
This feature exists since 0.9.29.
+
This feature was introduced in Lazarus 0.9.29.
  
 
=File encoding=
 
=File encoding=

Revision as of 17:01, 16 December 2013

Overview

IDE directives are similar to compiler directives: a special kind of comment placed in your source code. They are enclosed by curly brackets with an opening percentage sign. For example:

{%H-}

The compiler sees them simply as comments which it ignores. The IDE uses these directives to store source-specific information which is independent of project and session.

Hide one hint, note or warning

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

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

end;

Note: You can right click on a hint in the message window and choose the context menu option "hide message via directive" to insert the directive automatically.

This feature was introduced in Lazarus 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

  • {%BuildCommand ...}
  • {%BuildWorkingDir ...}
  • {%BuildScan ...}
  • {%RunCommand ...}
  • {%RunWorkingDir ...}
  • {%RunFlags ...}

See Configure Build File.

Other IDE Directives

  • {%Region} Allows to define your own Code Folding blocks, by putting this special comment into the code. ends with {%Endregion}

Reading / finding IDE directives

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

  • FindNextIDEDirective
  • CodeToolBoss.GetIDEDirectives