Database Reference
In-Depth Information
NOTE
If the script doesn't work, you have options. First, check your data to make sure you have appropri-
ate timeslips and expenses for the script to work on. Second, you can surf over to this topic's Miss-
ing CD page at www.missingmanual.com/cds/fmp13tmm and compare your scripts with the ones in
this chapter's finished file. But if you have FileMaker Pro Advanced, you should also read about the
Script Debugger and Data Viewer in Chapter 13 . These tools make hunting down script problems
much easier, and few serious scripters work without them.
In this chapter, you walked through a lengthy task where the steps and outcome were known.
Out there on the mean streets of development, you won't always have a roadmap to follow.
Still, the concepts of planning, exception handling, and efficiency will get you out of a lot of
sticky script situations.
TIP
And even if your database doesn't handle invoicing, it's very common to create related records and
move data via scripts so that you can retain control over data. Just adapt these scripts to meet your
needs.
When you're first learning to write scripts, or if you're attempting to do something that you
aren't quite sure will work, following an approach like the one above will serve you well. In
addition to creating your scripts in comment and subscript form, you can break scripting
down even further. Create a few script steps and then test them to make sure they behave as
you expect. If they don't work properly, tweak them until they do. Then add a few more
script steps and test again. If a new problem arises, you know it's in the new steps you've
just added.
Finally, don't forget that the state of your database can influence what happens when you test
a script. For example, a button on the Jobs layout ensures that your users can run the “Create
Invoice for Jobs” script only from the proper context. But in the heat of testing, you might
accidentally run the script from the Manage Scripts window while you're on the wrong lay-
out. If you do, the script won't have a Job ID to work with, and all kinds of havoc will be
loosed in the script: It won't know which unbilled items to search for and could create an In-
voice that's not attached to any job at all.
As you gain experience, you'll find that planning, finding exceptions, and subscripting be-
comes second nature. You'll start envisioning scripts of increasing complexity, and soon
you'll be making them your own way, without following a rigid plan.
Search WWH ::




Custom Search