Modifier

Partager via


Region directive in AL

APPLIES TO: Business Central 2020 release wave 2 and later

Region

The #region directive is used to mark a block of code that you can expand or collapse. This can, for example, be useful for larger files for better readability or for focusing on code that you're currently working on. The #endregion specifies the end of a #region block of code.

Note

On the first line of the #region a text comment can be added to describe the purpose of the block of code, see the following example.

Syntax

#region [comment]
    code
#endregion

Remarks

A #region block must be terminated with a #endregion directive.

A #region block can't overlap with an #if block. However, a #region block can be nested in an #if block, and an #if block can be nested in a #region block.

Example

In this example, the #region directive makes a code block that is up for refactoring collapsible.

#region Ugly code - let's not look at this
    procedure UglyCode()
    begin
        // No one should look at this
    end;
#endregion

Development in AL
AL development environment
Pragma directive in AL
Conditional directives
Deprecating explicit and implicit with statements