Database Reference
In-Depth Information
)
// Only X is defined here, too
)
You can also use the Let() function more than once in a single calculation without nesting:
Let ( [ X = 3; Y = 4 ] ; X * Y ) &
Let ( units = "inches" ; " " & units )
Recursion
As described in the box on Using Custom Functions , you can create custom functions that
call other custom functions, creating whole strings of mathematical wizardry that perform to
your exact specifications. Even more interesting, a custom function can use itself , a tech-
nique known as recursion . With recursion, you can create calculations that repeat a process
over and over again until they reach a result—called iterative calculations .
NOTE
Recursion is a notoriously complicated topic, and many very capable FileMaker developers are sty-
mied by it. Fortunately, recursion is rarely the only solution to a given problem, so you can certainly
get by without it. For example, consider using a script instead.
Imagine you need a function that removes duplicate lines from a list. For example, if a field
contains a list of colors, then you want a new list with only each unique color name, even if
it appears in the original list several times. You can't do that with a normal calculation, be-
cause you just don't know how many words you need to pull out. A recursive function solves
the problem by repeating its work until it takes care of all items.
Although the concept of a recursive function is simple, creating one can be tricky. To imple-
ment a recursive function, you're best off tackling the calculation in three distinct steps.
First, solve the initial problem; second, call that first formula over and over again (that's the
recursive part); and third, tell the formula how to stop.
NOTE
If you have trouble getting through the following recursion example on your own, you can down-
load a sample database from this topic's Missing CD page at www.missingmanuals.com/cds/fm-
p13mm .
Search WWH ::




Custom Search