Break and Continue Keywords

The EKL lets you stop a loop execution, and jump to the next iteration.

This page discusses:

Break

This keyword can be used in loops initialized using the for statement to stop this loop. When the script is interrupted, the script evaluation goes directly to the instruction located directly after the loop. Available on the client only.

Example

A script that computes the total length of several lines and stops computing once the total length is superior to 100mm.

Let i,result (Integer)
result = 0
i = 1
for i while i < lines.Size()
{
	           result = length(lines[i]) 
	           if result > 100mm
	           {
	                     	break
	            }
}

Continue

This keyword can be used within for loops. After calling continue, the script goes directly to the first instruction of the loop to start the next iteration. Available on the client only.

Example

Let i (Integer)
Let localResult(Real)
Let resultsList(List)
i = 1
for i while i < numerators.Size()
{
	      If divisor[i] <> 0
	      {
		                localResult = numerators[i]/divisors[i]
	                 if localResult[i] < 0
	                 {
			                         // This result is not interesting, let’s go to the next iteration
			
continue  
	                	}
		                         	Else
			                         {
			                                   	resultsList.Append(localResult)
		                         	}
	                 }
}