# DECIDE versus IF

**URL:** <https://techcommunity.softwareag.com/t/decide-versus-if/61919>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-News-and-General-Topics\
**Created:** [February 8, 2007, 2:03am UTC](https://techcommunity.softwareag.com/t/decide-versus-if/61919 "2007-02-08T02:03:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jennifer](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@Jennifer](https://techcommunity.softwareag.com/u/Jennifer)\
**Post date:** [February 8, 2007, 2:03am UTC](https://techcommunity.softwareag.com/t/decide-versus-if/61919/1 "2007-02-08T02:03:05Z")

</div>

Hi,  
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.

TIA,  
Jennifer

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [February 8, 2007, 3:03am UTC](https://techcommunity.softwareag.com/t/decide-versus-if/61919/2 "2007-02-08T03:03:47Z")

</div>

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

steve

---

<div class="post-metadata">

**Author:** ![Jennifer](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@Jennifer](https://techcommunity.softwareag.com/u/Jennifer)\
**Post date:** [February 8, 2007, 3:25am UTC](https://techcommunity.softwareag.com/t/decide-versus-if/61919/3 "2007-02-08T03:25:36Z")

</div>

That guideline helps a lot. Thanks!

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [February 8, 2007, 2:26pm UTC](https://techcommunity.softwareag.com/t/decide-versus-if/61919/4 "2007-02-08T14:26:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Lukas\_Hundemer](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/lukas_hundemer/32/113_2.png) [@Lukas\_Hundemer](https://techcommunity.softwareag.com/u/Lukas_Hundemer)\
**Post date:** [February 8, 2007, 3:57pm UTC](https://techcommunity.softwareag.com/t/decide-versus-if/61919/5 "2007-02-08T15:57:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:41pm UTC](https://techcommunity.softwareag.com/t/decide-versus-if/61919/6 "2021-04-02T14:41:03Z")

</div>


