FileMaker Pro Plug-Ins
Volume Number: 15
Issue Number: 1
Column Tag: Plugging In
External Function Plug-ins for FileMaker Pro
by David McKee
Edited by Michael Brian Bentley
An Introduction to Their Nature and Creation.
FileMaker Pro and Plug-ins
FileMaker® Pro software is the database of choice for Mac OS users; part of its
success has been due to the very accessible user interface. Much of what you do is
point-and-click. Up until recently, the closest to programming you could get is a very
complex calculation formula or script. Plug-ins introduce a level of programmability
never before available.
A script in FileMaker Pro is not unlike a macro in a word processing application.
Scripts are great for automating tasks you can do manually in the user interface such
as switching layouts or printing a report, but they must be initiated by the user.
Calculations are performed without user input and are adequate for typical usage,
since calculations are written in a high level syntax that is interpreted by the
FileMaker Pro calculation engine. Creating a formula merely requires that you
assemble a series of built-in functions from various categories.
A calculation formula like "fieldA + Sin(fieldB)" can be created entirely by the
point-and-click interface.
The problem is, formulas that require recursion or looping are not possible in
calculations. Typical kinds of functions are built-in, like trigonometric functions, but
industry-specific algorithms, like annuity functions based on payments at the
beginning of a period, are not.
Scripts support recursion and looping, but require the user to execute them.
Both calculations and scripts interact with other parts of a FileMaker Pro database.
The various parts of FileMaker Pro integrate well, but a database is closed to the
outside world of the OS and/or other applications. What if your calculation requires
some information from another SDK? What if you wanted to create your solution to
present to the user a very specific style of dialog boxes?
With AppleScript and the right scripting addition, you could achieve some sort of
integration with another application. With some layout tricks, you could simulate
dialogs. However, this just isn't the same as having a programmable feature within the
application that would give you direct access to the OS or another SDK.
FileMaker Pro "External Function Plug-ins" can bridge this gap between the
application's predefined interface and your need for a custom one. An API/SDK was
released for FileMaker Pro 4.0 that allows you to create your own compiled code that
can be referenced by a formula in a calculation, as an "External" function. When an
External function is referred to, FileMaker Pro passes program control over to the
external code you created. Your plug-in can then do what it needs to do and pass the
needed information (and program control) back to FileMaker Pro.
By using an External Function Plug-in, you can use calculation formulas that take
advantage of things like recursion and looping. Plug-ins can hook into other
applications or the Mac OS toolbox. This means things previously impossible with
calculations and scripts are now within the database developer's reach.
For brevity and focus, this article assumes you have at least a rudimentary knowledge
of FileMaker Pro calculation fields and scripts.
Terms
The following are terms used within this article. They are included for those new to
programming plug-ins or modules.
Plug-in
A plug-in is a file separate or external to the application that contains
executable code. The application loads the plug-in at runtime and passes
information and control to the plug-in whenever needed. The advantages of
putting some features in a plug-in include easier revision of the feature, as
well as allowing the application author to open up feature creation or
modification to the public without exposing sensitive parts of the program. A
plug-in is essentially a separate application that is complied as a code
resource or library. It inhabits the same application space as the host
program that loaded and passed execution to it.
Parameter Block
A Parameter Block is the sole shared data structure that gets passed between
the program and the plug-in. This allows data and functions to be passed
seamlessly, even though they are basically two separate applications. If a
particular function is not supported by the parameter block, then the desired
control or communication between the two entities is probably not possible.
API
An API, or Application Programming Interface, is a set of standards that your
application must adhere to in order for it to be usable with the host program
or standard. Some APIs are header and source code documents that you are
required to use when compiling your code, while other APIs are just header
files that allow you to link to a provided library. There are no extra libraries
needed to create a FileMaker Pro plug-in other than the ones you would
normally need to create a code resource or shared library.
SDK
An SDK, or Software Development Kit, is often used interchangeably with API.
External Function
An External function is a new class of calculation functions that can be used in
a calculation formula. First introduced in FileMaker Pro 4.0, functions in this
class are not built into the application. External functions can be designed and
used in two ways. When used from within a calculation field, as part of a
formula, the External function behaves as a function. In this case, the External
function returns data that will be used as part of the formula. When used from
a SetField script step, where an action is involved, the External function
behaves as a command. In this case, what the External function returns may
only be a result/error code.
External Function Plug-in
An External Function Plug-in is a third-party file that contains External
functions. These are loaded by the FileMaker Pro application upon startup. The
External functions are then listed in the calculation dialog box interface of
FileMaker Pro.
Feature String
A Feature String is a series of flags that inform FileMaker Pro how to utilize
the plug-in. Part of the Feature String is the "Feature String ID", which is
essentially a Mac OS creator code that uniquely identifies that plug-in. No two
plug-ins should have the same Feature String ID.