FileMaker Function of the Week: The Let Function
THE LET FUNCTION is the main function that allows you to write functions similar to php and other languages. You can declare variables on the fly that only exist while the function is evaluating, and not have to clean them up afterward. You can manipulate data to the nth degree and return a result (or not) that you can pass on. FullCity goes into more detail and ties it back to their example of the case statement:
When is a function kinda not really a function? Unlike most functions that do some predefined process for you and kick back a result, the Let function is more about streamlining complicated calculations. Let permits you to define what amounts to calculation variables at the top of the calculation and then refer to them by name throughout the rest of the calculation. In the abstract, here’s a model of a Let function.
item = determine the value of item>;
<calc that can refer to the above named item>
Supposing that you have to create some crazy complicated calculation to figure out the values for items 1 and 2, placing them at the top of the calc can make the whole thing much more wieldy. A concrete example will, I hope, crystallize the case for why Let can be so useful. Consider the calculation used in last week’s FMFotW:
You’ll have to visit the link below to see the rest. Practice with this function until you are comfortable with it. You will use it a lot.
via FileMaker Function of the Week: Let.