Reference > Functions reference > Logical functions > SetRecursion
 

SetRecursion

Sets the maximum number of iterations for recursion and loops within an expression.

Format 

SetRecursion ( expression ; maxIterations )

Parameters 

expression - any calculation expression, field, or constant.

maxIterations - the maximum number of iterations.

Data type returned 

text, number, date, time, timestamp, container

Originated in 

FileMaker Pro 18.0 Advanced

Description 

By default, the While function and recursive custom functions are each limited to 50,000 iterations. This function allows you to increase or decrease the limit to maxIterations. If maxIterations is exceeded, this function will return "?"; otherwise, it returns the result of expression.

Notes 

Custom functions that use non-tail recursion are also subject to maxIterations specified by SetRecursion. However, they will also terminate and return "?" if the available stack space in memory becomes too small, regardless of SetRecursion.

Example 1 

Returns "?" because the While loop attempts to iterate more than the limit of five times specified by SetRecursion.

SetRecursion (
While (
[ i = 0 ; out = "" ] ;
i ≤ 10 ; 
[
i = i + 1 ;
out = out & $variable[ i ] & ¶
] ;
out
) ;
5 )

Example 2 

Returns 100000 because SetRecursion increases the iteration limit to 200000.

SetRecursion (
While (
i = 0 ;
i < 100000 ; 
i = i + 1 ;
i
) ;
200000 )

Related topics 

Functions reference (category list)

Functions reference (alphabetical list)

About formulas

About functions

Defining calculation fields

Using operators in formulas