Database Reference
In-Depth Information
TIP
When you're writing multiple condition scripts, it can be hard to figure out when a condition tests as
True. See the section on the Script Debugger (
Script Debugger
) to learn how to watch your scripts
run step by step.
Looping
Sometimes you want to do the same thing over and over again, until you reach some kind of
end point. For example, people often write a script that does something to every record in the
found set, one after another. This script is called a
looping script
. You make a script
loop
through records
by using the
Loop
script step.
The
Loop
step comes immediately before the steps you want to repeat. Like an
If
test, the
Loop
step is part of a pair. Sometimes, you'll also use an
Exit Loop If
step, which lets you
write a calculation to figure out when the loop should stop. This step usually comes at the
end of the steps that'll repeat each time the loop runs and just before the
End Loop
step. The
Exit Loop If
calculation is evaluated every time the loop runs and then when the condition
is met, the script proceeds to the
End Loop
step and then executes any steps that come after
the loop is finished. FileMaker has three ways to exit a loop:
▪ The
Go to Record/Request
step has an “Exit after last” option when you go to the next
or previous record. That way, you can easily loop through all the records in the found set,
exiting the loop when you get to the last one.
▪ The
Exit Loop If
script step lets you provide a condition formula (just like
If
). If the
condition evaluates to True, then FileMaker immediately skips to the first step after
End
Loop
.
▪ The
Exit Script
and
Halt Script
steps both end a script immediately, even if you're in a
loop.
NOTE
If you forget to provide a way for a loop to stop, you can press Esc to stop it. Better yet, use the
Script Debugger FileMaker Pro Advanced whenever you're creating and testing scripts. See
Script