Database Reference
In-Depth Information
AmountDue < 0 ; AmountDue & "CR" ; AmountDue
)
)
In this example, you're including the last test condition within the scope of the Let() func-
tion, and you've switched to a Case() function, so that you don't have to read a set of nested
If() functions.
If you want the local variables you set inside calculations to follow the same naming conven-
tions as variables you set in scripts, then prefix their names with $ . In that case, you'd write
the calculation you just saw like this:
Let ( $AmountDue = Sum ( Line Items::Extended Price );
Case (
Get ( CurrentDate ) > Date Due and $AmountDue > 0;
$AmountDue + ( $AmountDue * .05 ) ;
$AmountDue < 0 ; $AmountDue & "CR" ; $AmountDue
)
)
NOTE
When you create a variable with a $ prefix in a calculation that evaluates while a script is running,
you extend its lifespan beyond the Let() function. In this case, the variable's scope is now the
script. This can cause problems if you accidentally give two variables the same name. In that case,
one variable will overwrite the other, and your script can go off the rails. Use this technique with ex-
treme care. See Script Variables for more information on how variables work in scripts.
Notice that you have to include the prefix in the Let() function, and in the formula that fol-
lows it.
Global Variables
FileMaker gives you global fields; it also gives you global variables . Unlike local variables,
global variables hold their results after the Let() function is finished. To create a global vari-
able, add a $$ prefix to its name. Here's the same calculation rewritten with a global vari-
able:
Let (
$$AmountDue = Sum ( Line Items::Extended Price ) ;
Case (
Get ( CurrentDate ) > Date Due and $$Amount Due > 0 ;
$$AmountDue + ( $$AmountDue * .05 ) ;
$$AmountDue < 0 ; $$AmountDue & "CR" ; $$AmountDue
Search WWH ::




Custom Search