alguidelines/content/BCBestPractices/Readability/begin-end/index.md
2021-12-11 08:29:14 +01:00

1.3 KiB

+++ title = "Begin-End - Compound Only" weight = 240 +++

<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)

Discussions

You can find discussions on all "Best Practices" here.

If you don't find the discussion of this guideline, please feel fee to create a new one with the same title as this article.