Custom functions are without a doubt one of the most powerful features in FileMaker; we cannot advocate their use strongly enough.
Simply described, custom functions become available in the calculation dialog as additional functions for use within expressions. They are snippets of code that, just as FileMakers pre-established functions do, accept parameters and produce output. One example might be
fnCommission (unitPrice; quantity; discount)
This function would then presumably return a dollar amount based on some formula that multiplied unitPrice and quantity, subtracted a discount from the total, and then applied a percentage or some internal factoring to arrive as a sales commission.
Note that as a developer using the function, we need not even know what that formula might be. All we require is, when fed the three parameters in question, that the function return a meaningful and consistent result.
For example, if ever an organizations commission rates needed to change, the developer could edit a single custom function and all the calculations based on that function would immediately (depending on their storage settings) reflect and make use of the change.
Custom functions allow developers to abstract portions of their code, independent from database schema or scripts, where its possible to reuse a particular piece of logic throughout ones database (or, by recreating the function in other files, across dozens of databases).
Custom functions can also serve as permanent "system variables" that are not subject to session issues as global fields and global variables are. The values within a custom function do not expire at the end of a users session, they are consistent across all users of a database, and a developer can change them centrally as needed.
For more detail and explanation on custom functions, see Chapter 14, "Advanced Calculation Techniques," in our companion book, Special Edition Using FileMaker 8.
: FileMaker Specifications
FileMaker 8 Product Line
Specifications and Storage Limits
Field Types and Import/Export Formats
: Calculation Functions
Working with Calculations Primer
: Custom Functions
Custom Functions Primer
Useful Custom Functions
: Script Steps
Script Step Reference
: Quick Reference
FileMaker Error Codes
FileMaker Keyboard Shortcuts
FileMaker Network Ports
FileMaker Server Command Line Reference
FileMaker XML Reference
: Other Resources
Where to Go for More Information