Organizing Complex Scripts
Sometimes you need a script that does a lot. At the end of this chapter you’ll build a script that generates an invoice for a selected job. As you’ll see, this process involves many steps across several tables. To do all this work in one long script can be cumbersome, especially when several levels of If and Loop steps get mixed up with each other.
In other situations, you may need two or more scripts that do similar things. In fact, sometimes, entire sections of two scripts are identical with only minor differences. You may have a script that finds unpaid invoices so it can print a statement, and another that finds unpaid invoices to send email payment reminders.
If you build these two scripts independently, you have two problems. First, you have to write all the “find the unpaid invoices” stuff twice, which is a waste of time. More importantly, next month when you realize you need to exclude voided invoices from the list, you’ll have to remember to make the change in both places. A database that’s been growing for years can be a real bear to manage if the same general business logic is implemented over and over in dozens of different scripts.
In both these situations, you can improve your prospects by dividing your scripts into smaller parts. That way, you can break up a complex script into simpler scripts that each do part of the job. Also, you can make one script that finds unpaid invoices and use it in another script that prints a statement and/or sends ...
Get FileMaker Pro 9: The Missing Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.