Database Reference
In-Depth Information
Figure 17-19. This script improves on the one in Figure 17-18. It checks for standard editing
keys—those with a code below 32 and the Forward Delete key, which is code 127. If any of those
keys are entered, the script exits. If any other key is entered, the script uses the same logic as before
to reject non-numeric keystrokes, and any entry beyond five digits. Now people can edit the field
with ease. (Check the completed scripts in Invoices_FINISHED.fmp12.)
To finish up, take a look at the modes you're applying the trigger in. You might be tempted
to assign the trigger for both Find and Browse mode, but remember that you might want to
find a range of Zip codes (46077-90201) or use a wildcard in your Zip Code search (852*).
So you're probably better off applying this trigger only in Browse mode.
Now when you test the script trigger, you should see better behavior. If you type text or
punctuation into the Zip Code field, FileMaker beeps, and nothing appears in the field. But if
you type a number key, it goes right in. And once the field has five numbers, it rejects any
additional entry.
Putting a Complex Script Together
Building a complicated script takes time and planning. Because scripting gives you so much
flexibility, you often have many ways to solve the same problem. Your job is to find the way
that best meets your business needs and is the simplest to understand, fix, and maintain later.
Plus as your skills grow, the approach you take to solving problems will change.
In this section, you'll make a script that generates an invoice for a job. You want to gather all
the unbilled expenses and timeslips for the job and then add the appropriate line items to the
invoice. To make a script like this, you need to cover all your bases:
Planning . Before you even start writing the script, you have to decide upon a general ap-
proach. Outline all the things your script will do, and in what order. This process usually
Search WWH ::




Custom Search