topic hubAL Developmentofficial - Microsoftunreviewed - model text not yet checked

Program building blocks

Program building blocks in AL: statements, operators, system-defined variables, access modifiers, and XML comments. It answers questions about AL syntax, expressions, branching and looping, symbol visibility, and inline documentation.

Path: Development > Programming in the AL language > Program building blocks · tier official · system development · narrative unreviewed (model text not yet checked)

Overview

This section covers the basic elements used to write AL code. Statements are the core: simple statements (assignment, method calls, AssertError) and control statements (if-then-else, case, for, foreach, while, repeat-until). Operators are used inside expressions for arithmetic, comparison, logical, conditional and compound operations.

The other pages cover the context and structure around the code. System-defined variables such as Rec, xRec, CurrPage, CurrReport and RequestOptionsPage give access to the current record, page or report. Access modifiers control the visibility of objects and members. XML comments document code inline.

Start with Statements and AL operators to learn the syntax. Then read system-defined variables for runtime context. Use access modifiers and XML comments when designing APIs and documenting them.

Key points

  • Statements include simple ones (assignment, method calls, AssertError) and control ones (if-then-else, case, for, foreach, while, repeat-until).
  • AL operators include arithmetic, comparison, logical, conditional and compound assignment operators. The page also covers operator hierarchy and data type conversion rules.
  • System-defined variables include Rec, xRec, CurrPage, CurrReport, RequestOptionsPage and CurrFieldNo.
  • Access modifiers are internal, local, protected and public. They control visibility of tables, fields, codeunits and queries at compile time.
  • The internalsVisibleTo setting lets other modules see internal members.
  • XML comments use triple slashes and supported XML tags on codeunits, tables, interfaces and methods.
  • XML comments feed IntelliSense and autogenerated help with ALDoc.

Subtopics

More Learn pages

  • AL operators: Describes the operators you can use in AL for Business Central.
  • System-defined variables: Describes the system-defined variables that are automatically declared and initialized in AL for Business Central.
  • Using Access Modifiers in AL: Describes how the AL access modifiers can be used in code.
  • XML comments in code: Learn about adding documentation to AL code by including XML elements in a special syntax.

Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.

What Learn documents here 6 Learn pages