Database Reference
In-Depth Information
)
)
The $$ prefix is the only difference you can see in the calculation. But the practical differen-
ce is vast: Global variable values remain until you change them (through another calculation
or through a script), or until you close the file.
NOTE
FileMaker Pro Advanced's Data Viewer ( The Data Viewer ) eliminates guesswork by letting you
check the contents of variables, whether you create them in calculation fields or from scripts.
You could run a script that checks to see if a payment was made within 10 days of the in-
voice date, and if it was, apply a one-percent discount to the $$AmountDue field. Sure, you
can do something similar with a straightforward calculation field, but in that case, it gets a
little trickier to apply the discount to some of the records, but not to others. With a script, you
can find the records you want to give a spur-of-the-moment discount, run the script on that
found set, and you're done.
Another reason to set a global variable with a calculation is to use that variable to filter
portals ( Portal Filtering ). Portals that are filtered by variables may not always refresh when
you expect them to because portals don't change their display unless a change of context
(like moving to a new record) also occurs. Portal filtering by variable is usually safer in a
script, because you can add a Refresh Window script step or a change of context to the script
to make sure the portal refreshes when the variable is changed. But using a calculation may
fit the bill in some situations, so you should know that it's possible.
Nesting Let() Functions
As with other functions, you can nest Let() functions inside one another. In fact, you can
define a variable once and then redefine it inside a nested Let() function. The variable's
value changes while inside the nested Let() function and then changes back when it ends.
By the same token, you can define a variable with the same name as a field , and FileMaker
uses the variable's value while inside the Let() function. (These techniques aren't com-
monly used except by programmers who want to use the same techniques in FileMaker as
they use when they write code.)
Here's a very simple example of a Let() function inside another Let() function:
Let ( X = 3 ; // only X is defined here
Let ( Y = 4 ; // X and Y are both defined here
X * Y
Search WWH ::




Custom Search