The EGL exit statement
exits from a function, program, service, or run unit or from a block
of code controlled by a case, for, forEach, if,
or while statement.
If you specify a controlling statement such as while,
the exit statement must be enclosed by the
controlling statement and must be in the same function.
Syntax
- label1
- A label that immediately precedes a statement of a supported type: case, for, forEach, if,
or while.
The exit statement
causes processing to continue with the referenced statement.
- program
- Use of the program keyword indicates that the exit statement
terminates the program. This keyword is available only in a program.
- returnValue
- A return value, which must be an expression that resolves to an
integer.
- rununit
- Use of the rununit keyword indicates that the exit statement
terminates the run unit. This keyword is available in a program or
handler and not in a service.
- statementType
- The nearest enclosing statement of the specified type. One of
the following keywords: case, for, forEach, if,
or while.
The following example shows an
exit statement
that transfer control to a labeled statement:
package client;
program MyProgram
function main()
i int = 3;
myLabel1: while(i == 3)
SysLib.writeStdOut("labeled");
for(x int from 1 to 5)
Syslib.writeStdOut("in for loop for x = " + x);
if(x == 4)
syslib.writeStdOut("x = " + x);
i = 4;
exit myLabel1;
end
end
end
syslib.writestdout("leaving");
end
Compatibility
Table 1. Compatibility
Target |
Issue |
Java |
No issues |
JavaScript |
Support is provided only for following variations
of the exit statement: exit case, exit
for, exit if, and exit while.
|