Exit Statement

A method or a loop in a method can be interrupted by using the exit statement:


Syntax:
exit [<label>] [when <condition>]
Note: label can be the method name or a labeled loop. The condition can be used to avoid cluttering your code with a conditional statement.
The following example finds the first e-mail containing a specific subject then exits the loop:
// order is a variable of type Fuego.Net.Mail

order as Mail
url as String = ""
	
for each mail in MailServer(url, false).messages do
    if mail.subject = "New Order" then
        order = mail
        exit
    end
end
	
// if there is no order to process,
// stop method execution	exit when
// order is null.
The second example finds a participant, assigns it to the nextParticipant variable, and ends the method execution. The name of the method is findParticipant:
participantName = "John"

for each p in activity.role.participants do
    if p.name = participantName then
        // participant found!
        nextParticipant = p
        exit : findParticipant   
        // findParticipant is the name of the method
    end
end

For further information refer to topics:

Related concepts
Bounded Loops
Labeled Statement
Related information
c_Compound_Statement.html#concept_BE4228DC74954A59A0A2017FF3F3BBE2