Scripts in FileMaker Pro

Scripts are sets of stored instructions that specify a series of actions FileMaker should perform when they're initiated; they're programs that run within FileMaker Pro solutions. They can be just one command attached to a button, or they can be hundreds of commands long.

Scripts do two important things in FileMaker Pro: They automate internal processes, and they add interactivity to custom user interfaces. Internal processes might consist of such things as creating a batch of monthly invoices, setting the status of sales leads, or exporting data for an aggregated report. And by "adding interactivity" we refer to the capability to create interface elements (such as buttons or icons) that will do something in response to user actions. Scripts help with both of these needs.

Scripts are written in FileMaker Pro's ScriptMaker, a point-and-click interface. Scripts can perform tasks ranging from simple things (such as simply entering Find mode) to complex automated import/export processes, multitable reporting, data reconciliation, and really anything that can be expressed as a programmed series of FileMaker steps.

It's a bit of an oversimplification, but you can think of scripts as automating a process that a human using your database solution might perform by hand.

After a script is initiated through some user action or external trigger (we'll cover how scripts get initiated later in the chapter), it runs in sequence from its first step to the last, exiting or ending after it is complete. Here's a simple example:

 

[View full width]

Show All Records Go to Record/Request/Page [ First ] Beep Show Custom Dialog [ Title: "First Record"; Message: "This is your first record."; Buttons : "OK" ]

As you can see from this short example, FileMaker Pro scripts are easy to read and comprehend. This script resets the found set of the current layout/window to consist of all the records in a given table, then takes the user to the first record in that set, beeps, and shows a dialog box with an OK button. Each step of the script is executed in order: Show All Records is completed, and then Go to Record/Request/Page is dealt with.

It's possible to create branching scripts by using logical If statements, and it's also possible to construct scripts that execute other scripts (hereafter referred to as subscripts). We'll get into both such techniques later in the chapter.

We have found over the years that the best way to learn scripts is to be presented with examples. We will endeavor in this chapter to review what we consider important and widely applicable topics for scripts and to provide as many examples as these pages allow.

Категории