AL control statements
Control statements execute the decision-making and resultant logic branches in executable code. The if
-then
-else
conditional statement, as discussed in Chapter 6, Introduction to AL, is also a member of control statements.
Here, we will discuss the following repetitive statements, conditional statements, and flow control methods:
repeat
-until
while
-do
for
-to
andfor
-downto
case
-else
Quit
,Break
,exit
, andSkip
Tip
For more possibilities (foreach
), programming conventions, and examples, visit the AL control statements page in the Microsoft docs at https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-al-control-statements.
repeat-until
repeat
-until
allows us to create a repetitive code loop, which repeats a block of code until a specific conditional expression evaluates to true
. In that sense, repeat
-until
defines a block of code, operating somewhat like the begin-end
compound statement...