Gentee Programming Language > Documentation > Syntax Download documentation

return, break, continue Instructions

The return instruction is used either to return a function value or to terminate the execution of a function. The exit may be from anywhere within the function body, including loops or nested blocks. If the function returns a value, the return instruction is required, furthermore it contains the expression of the appropriate type.

<return> ::= return [<expression>]

{
...
fornum i, 100
{
if error
{
return 0 // terminating the execution of the function
}
...
}
...
return a + b
}

The break instruction terminates the execution of the loop. break is likely to be located within nested blocks. If a program contains several nested loops, break will exit the current loop.

while b > c
{
for i = 100, i > 0, i--
{
if !myfunc( i )
{
break //terminating the execution of for loop
}
}
b++
}

The continue instruction may occur within loops and attempts to transfer control to the loop expression, which is used to increment or decrement the counter (for the following loops: for, fornum, foreach) or to the conditional expression (for while and do-while loops); moreover, the execution of the loop body is not completely executed. The instruction executes only the most tightly enclosing loop, if this loop is nested.

fornum i, 100
{
if i > 10 && i < 20
{
continue
}
a += i//The given expression is not evaluated if i>10 and i<20
}

See also

    while, do-while Statement    for and fornum Statements    foreach Loop Statement


 Copyright © 2004-2006 Gentee Inc. All rights reserved.