Conditional statements
Conditional statements are the heart of process flow structure and control.
The BEGIN–END compound statement
In C/AL, there are instances where the syntax only allows for use of a single statement. But a design may require the execution of several (or many) code statements.
C/AL provides at least two ways to address this need. One method is to have the single statement call a function that contains multiple statements.
However, inline coding is often more efficient to run and to understand. So C/AL provides a syntax structure to define a Compound Statement or Block of code. A compound statement containing any number of statements can be used in place of a single code statement.
A compound statement is enclosed by the reserved words BEGIN
and END
. The compound statement structure looks like this:
BEGIN <Statement 1>; <Statement 2>; .. <Statement n>; END
The C/AL code contained within a BEGIN – END
block should be indented...