Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EDT:Writing statements"
Line 9: | Line 9: | ||
*You can test a criterion value. The following example invokes <code>mySecondFunction</code> if the field value is 2, 3, or 4: | *You can test a criterion value. The following example invokes <code>mySecondFunction</code> if the field value is 2, 3, or 4: | ||
− | <source lang="java"> | + | <source lang="java"> |
− | when (1) | + | function test() |
− | + | x Int = 3; | |
− | + | ||
− | + | case (x) | |
− | + | when (1) | |
− | + | myFirstFunction(); | |
− | end | + | when (2, 3, 4) |
+ | mySecondFunction(); | ||
+ | otherwise | ||
+ | myDefaultFunction(); | ||
+ | end | ||
+ | end | ||
</source> | </source> | ||
Line 23: | Line 28: | ||
<source lang="java"> | <source lang="java"> | ||
function test() | function test() | ||
− | x | + | x Int = 3; |
− | y | + | y Int = 5; |
− | z | + | z Int = 7; |
case | case |
Revision as of 12:09, 13 February 2012
EGL provides general statements, as well as statements that are used for interacting with an external data source.
General statements
Case
The case statement never runs more than one clause:
- You can test a criterion value. The following example invokes
mySecondFunction
if the field value is 2, 3, or 4:
function test() x Int = 3; case (x) when (1) myFirstFunction(); when (2, 3, 4) mySecondFunction(); otherwise myDefaultFunction(); end end
- You can test a set of logical expressions. The following example displays only "x passes":
function test() x Int = 3; y Int = 5; z Int = 7; case when (x == 3) SysLib.writeStdOut("x passes"); when (y == 5) SysLib.writeStdOut("y passes"); when (z == 7) SysLib.writeStdOut("z passes"); otherwise SysLib.writeStdErr("You will not see this message."); end end end