alguidelines/content/docs/BestPractices/begin-end/index.md
Henrik Helgesen fb17dc9640 Removed Discussion Links. Using new Theme solution.
Some additional MDLint cleanup as well
2022-02-24 15:36:06 -08:00

921 B

title tags categories
Begin-End - Compound Only
AL
Readability
Best Practice

Created by Microsoft, Described by waldo

Only use begin..end to enclose compound statements.

Bad code

if FindSet() then begin
    repeat
    ...
    until next() = 0;
end;

Good code

if FindSet() then
    repeat
    ...
    until next() = 0;

Bad code

if IsAssemblyOutputLine then begin
    TestField("Order Line No.", 0);
end;

Good code

if IsAssemblyOutputLine then
    TestField("Order Line No.", 0);

Exception

// Except for this case
if X then begin
    if Y then 
        //DO SOMETHING;
end else 
    (not X)