Database Reference
In-Depth Information
( 1 + 1 + 1 ) + 3
In this case, the sub-expression (1 + 1 + 1) has replaced the original value 3. The whole thing
is a new expression, and it contains one sub-expression. While the nested expression ex-
ample is very simple, the concept behind it gives you a lot of power when you work with
functions. Instead of using individual fields or constants in a function, you can pass along
whole expressions. You can even nest functions within other functions (see Nesting Let()
Functions ).
UP TO SPEED: THINK LIKE A MACHINE
If you've jumped right in and started making perfect calculations every time, then you can skip this
bit of arcana. But if FileMaker throws up a warning dialog box every time you try to make a
halfway complex calculation, or if the syntax seems fine, but you just aren't getting the math to
work out right, then you might have to try thinking like FileMaker thinks. To understand how fields,
constants, functions, and operators come together to produce a single result, you have to think very
logically and in a straight line that inexorably leads to the end of a problem. When FileMaker evalu-
ates a calculation, it looks for something it can do to simplify it—fetch a field value, perform a func-
tion, or evaluate an operation.
The calculation shown in Figure 9-5 has a function (average), several operators ( * and & ), a constant
( cubic inches ), and six fields ( L1 , W1 , H1 , L2 , W2 , H2 ). You might think the average function is the
right place to start, because it comes first. But you quickly realize you can't compute the average
until you figure out what its parameters are by performing the multiplication. The * operators mul-
tiply values on either side to produce a new value—but FileMaker needs to replace these fields with
their values before it can do anything else.
In step 1, FileMaker identifies six fields. Step 2 shows how the calculation looks once FileMaker re-
places them with values.
Now the * operators are all surrounded by values, and FileMaker is ready to do some multiplication.
Step 3 shows the calculation once all the multiplication is finished.
At last, the Average() function has two parameters, which is just what it needs, so FileMaker per-
forms this function, and the new calculation looks like step 4.
You have no more fields to replace and no more functions to perform, but there's one last operator.
The & operator takes two values and puts them together (step 5). With all the steps completed,
FileMaker can now display the final result. Finally, the & operator is evaluated, and step 9 shows
the calculation result.
If you apply the concepts outlined here to your problem calculations—find the answer to each step
and then plod along to the next one—you can always figure out where your calculation has gone
astray.
Search WWH ::




Custom Search