DECIDE versus IF

I’m new to Natural and am in need of help. I don’t understand when to use an IF versus a DECIDE ON statement. Is it a matter of preference? It seems like the usage of either are interchangeable.


You will probably get responses from “both sides of the aisle”; meaning there will be people who always use DECIDE, and those who do not use DECIDE.

I view the “power” of DECIDE as being the WHEN ANY, WHEN ALL, and WHEN NONE clauses. If I have no use for these clauses in a particular portion of code, I tend to use IF; if I need them, I use DECIDE.

You might check, however, some shops actually have edicts as to which should be used (a silly scenario in my mind).


That guideline helps a lot. Thanks!

DECIDE … FIRST is sematically equivalent to nested IFs, but more readable, regarding indentation.
DECIDE … EVERY is sematically equivalent to a sequence of IFs, but more readable regarding lines of code (instead of END-IF IF only a single line WHEN/VALUE).
And, of course the WHEN ALL/ANY, that must be codes as switches/counters in IF statements.

If I have a simple
structure, I use the IF statement.
If it looks more complicated (more cases), I use the more readable DECIDE statement.