Difference between revisions of "IF a THEN b ELSE c"

 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Analytica User Guide]]
 
[[Category:Analytica User Guide]]
<languages />
+
<breadcrumbs>Analytica User Guide > Expressions > {{PAGENAME}}</breadcrumbs>
<translate>
 
[[Analytica User Guide]] > [[Using Expressions]] > [[IF a THEN b ELSE c]]
 
  
This conditional expression returns '''b '''if '''a '''is true (1) or '''c '''if '''a '''is false (0), for example:
 
  
:'''Variable X := 1M'''
+
This conditional expression returns «b» if «a» is true (1) or «c» if «a» is false (0), for example:
 +
:<code>Variable X := 1M</code>
 +
:<code>Variable Y := 1</code>
 +
:<code>IF X > Y THEN X ELSE Y &rarr; 1M</code>
  
:'''Variable Y := 1'''
+
returns the larger of <code>X</code> and <code>Y</code>.
  
:'''IF X > Y THEN X ELSE Y &rarr; 1M'''
+
It is possible to omit the '''ELSE''' clause:
 +
:<code>IF X > Y THEN X</code>
  
returns the larger of '''X '''and '''Y'''.
+
If the condition is false, it gives a warning. If you ignore the warning, it returns [[Null]].
  
It is possible to omit the '''ELSE '''clause:
+
Conditional expressions get more interesting when they work on arrays. See [[IF a THEN b ELSE c with arrays]].
  
:'''IF X > Y THEN X'''
+
==See Also==
 +
* [[If-Then-Else]]
 +
* [[IF a THEN b ELSE c with arrays]]
  
If the condition is false, it gives a warning. If you ignore the warning, it returns '''NULL'''.
 
  
Conditional expressions get more interesting when they work on arrays. See [[IF a THEN b ELSE c with arrays]].
+
<footer>Operators / {{PAGENAME}} / Function calls and parameters</footer>
 
 
==See Also==
 
{| style="margin: 1em auto 1em auto;width: 100%;border:0;table-layout: fixed;" cellpadding=5
 
|- style="text-align: center"
 
| [[Operators]] <- || [[IF a THEN b ELSE c]] || -> [[Function calls and parameters]]
 
|}
 
</translate>
 

Latest revision as of 00:13, 1 June 2016


This conditional expression returns «b» if «a» is true (1) or «c» if «a» is false (0), for example:

Variable X := 1M
Variable Y := 1
IF X > Y THEN X ELSE Y → 1M

returns the larger of X and Y.

It is possible to omit the ELSE clause:

IF X > Y THEN X

If the condition is false, it gives a warning. If you ignore the warning, it returns Null.

Conditional expressions get more interesting when they work on arrays. See IF a THEN b ELSE c with arrays.

See Also


Comments


You are not allowed to post comments.