Working with Iterative Loops

The following are functions that can be used to manage loops. To implement these functions, you must be running Lotus Notes release 6 or greater.

Function

Description

Example

@For

Executes one or more statements while the specified condition remains true. After each execution, the condition is rechecked to verify that the statement remains true. Syntax:

@For ( initialize; condition; increment; statement);  

initializeThe starting value for the loop counter.

conditionA true or false condition.

incrementA statement that changes the counter.

statementA formula language statement to execute. Up to 254 statements can be specified.

The following loops through the elements of a keyword field called Options. With each iteration, a counter called cntr is incremented and the keyword element is displayed to the user.

@For(cntr:= 1; cntr <= @Elements(Options); cntr:= cntr + 1; @Prompt([OK]; "Item " + @Text(cntr)" is "; Options[cntr]))  

@While

Executes one or more statements while the specified condition remains true. Syntax:

@While ( condition; statement );  

conditionA true or false condition.

statementA formula language statement to execute. Up to 254 statements can be specified.

Note: There is also a @DoWhile statement, which was introduced in release 6.

The following loops through the elements of a keyword field called Options. Each element is displayed and a counter is incremented with each loop.

cntr:= 1; @While(cntr >= @Elements(Options); @Prompt([OK]; "Item " + @Text(cntr)" is "; Options [cntr]); cntr:= cntr + 1)  

Working with Lookup Functions

Категории