Conditional structures: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 2,842: | Line 2,842: | ||
CheckIt 0 |
CheckIt 0 |
||
CheckIt -100 |
CheckIt -100 |
||
</lang> |
|||
===[IF() AND IF$() - Ternary]=== |
|||
One expression evaluated only. We can use If$() to use string expressions |
|||
<lang M2000 Interpreter> |
|||
Module Checkit { |
|||
Read x |
|||
Print If(x>100-> 100, x) |
|||
} |
|||
Checkit 30 |
|||
Checkit 300 |
|||
\\ we can use more than two expressions, if i is not in range then 0 returned |
|||
Module Checkit { |
|||
Read i,x |
|||
Print If(i-> x*5, x*40, x*500) |
|||
} |
|||
Checkit 1, 20 |
|||
Checkit 2, 20 |
|||
Checkit 3, 20 |
|||
</lang> |
|||
===[SELECT CASE]=== |
|||
We can use string, and three types of cases (all of them in one case), >1000, 10 to 40, 400 |
|||
<lang M2000 Interpreter> |
|||
Module CheckIt { |
Module CheckIt { |
||
Read a |
Read a |
||
Line 2,860: | Line 2,885: | ||
CheckIt 0 |
CheckIt 0 |
||
CheckIt -100 |
CheckIt -100 |
||
</lang> |
</lang> |
||
=={{header|Make}}== |
=={{header|Make}}== |