continue

Table of Contents

Overview

The continue statement skips a particular iteration within a loop based on specified condition and continues with the iteration process. Typically used instead of using conditional statements to skip/ignore certain portion of a loop.

Syntax

continue;

The syntax can be placed within the loop after a conditional statement. When the condition is met, the current iteration is skipped while the loop continues.

Examples

Example 1

In the following example, "li" is a list containing colours "Blue", "Green" and "Red". While iterating through the list, when "Green" is found, the iteration is skipped for "Green" and the other list values are returned.

li = List();
li.add("Blue");
li.add("Green");
li.add("Red");
for each rec in li
{
if(rec == "Green")
{
continue;
}
info rec;
}

Example 2

Let us say we have a list of "Delivered" orders and "Pending" orders. To send a mail to "Pending" Orders and skip "Delivered" orders, we can use the "continue" statement as shown below:

for each order in Orders
{
if(Status == "Delivered")
{
sendmail
[
from: <enter an email ID or valid zoho variable>
to: <enter an email ID or valid zoho variable>
subject: <Enter a Subject>
message: <Enter your Message>
]
continue;
}

In this case, a mail can be sent to owners of "Pending" orders and the loop can be continued by removing "Pending" orders from the list for further use.

Share this post : FacebookTwitter