NAV2013 Beta to RTM – Some Striking Code Changes #7: CASE Layout

Although the coding standards are unambiguous about the layout of CASE statements, there has always been practiced an alternative flavor. Both within MS and outside.

This is the standard syntax:

CASE <Expression> OF
  <Value set 1>:
    <Statement 1>;
  <Value set 2>:
    <Statement 2>;
...
...
  <Value set n>:
    <Statement n>;
END;

And this is the alternative flavor:

CASE <Expression> OF
  <Value set 1>: <Statement 1>;
  <Value set 2>: <Statement 2>;
...
...
  <Value set n>: <Statement n>;
END;

Note that:

  • the alternative is only used when the statement following the value set is a single line statement (see also the screen shot)
  • I have left out the optional ELSE part for clearness sake.

However, as said, the coding standards are unambiguous about the layout stating:

The action [i.e. the statement – lvanvugt] starts on the line after the value set and is further indented by two character spaces.

Meaning that the alternative flavor is not part of these standards and now with NAV 2013 you could say that has been confirmed by means of the code cleanup performed between Beta and RTM, where all alternative layouts have been revised and changed to the standard layout.

The alternative is more compact, but the standard is more clear in displaying the ‘available’ value sets.

Click on the images to get a full view that’s readable.

Update 20121104

Found another nice example:

Leave a Reply

Your email address will not be published.