Database Reference
In-Depth Information
happens when he clicks the button to create an invoice for the job. The dialog box should
explain why FileMaker isn't creating an invoice.
Add an Else step . Since you don't want to create an invoice if there aren't any billable
items for the job, put an Else step after the Show Custom Dialog step and put the re-
maining TODO items in the Else part of the If test. The End If step should be at the
end of the script.
Creating Subscripts
Now that you've figured out how to solve problems your script might encounter, you've
come to a fork in the road. You can write a script containing all the necessary steps, but it'll
be long and hard to follow. For example, the End If steps at the end of the script will be a
long way from their If and Else counterparts, making it hard to figure out where they be-
long. The script will be easier to read and troubleshoot if you break it up into smaller, more
manageable pieces.
When you're trying to decide whether to write one long script or several shorter ones, you
might consider a few other things. If you have several small scripts, you can run any one of
them individually. This method gives you the chance to try out parts of the script to see if
they work properly. Also, since you can pass errors, or script results to scripts via script para-
meters, using subscripts to do some jobs often saves you the trouble later on. But in the end,
either approach is perfectly valid. Some people really like short, simple scripts, even if it
means more of them. Others prefer to put everything controlling a single process into the
same script, no matter how long the script gets.
Creating Subscript Placeholders
For this example, you'll be creating subscripts. Use the comment steps you wrote earlier to
figure out what subscripts you'll need. Then you can create placeholders for them by putting
Perform Script steps underneath the appropriate comments. Figure 17-22 shows a repeat
of your script-in-progress with places for subscripts clearly identified.
Each of these scripts is relatively short and easy to understand, but you'll have five scripts in
all. (See the box on The Right Way to Create Subscripts for some tips for breaking up long
scripts into subscripts.)
Search WWH ::




Custom Search