Read an Excerpt
Chapter 2: ScriptMaker: The Basics
2.0 ScriptMaker
A macro language
In this chapter, you'll learn the basics of ScriptMaker - how it's useful and why you should use it. Though much of FileMaker Pro's raw power lies in ScriptMaker, scripting is one of the last areas most users explore. If you've been working with FileMaker Pro without using ScriptMaker, hang on and buckle up for the ride of your life.
2.1 What is ScriptMaker?
ScriptMaker isn't a computer language like BASIC, Pascal or C/C++. ScriptMaker is basically a macro generator. What's a macro? It's a sequence of steps that run in a linear fashion to automate a process that would other-wise be performed manually. What you get with ScriptMaker, that you don't get with other macro languages, is a dynamic environment. Once finished, you can end up with many scripts (macros) that create a feature set. One script can call another script, which can, in turn, call yet another script. Scripts can also make logical decisions (If statements) and perform repetitive tasks (Looping statements).
Scripting is what makes a database solution equivalent to a piece of software. So, in the truest sense, you are programming when creating functional scripts. You can even think of ScriptMaker as quasi object-oriented. While it could be argued that it is unlike object oriented programming (because it lacks aspects such as inheritance, classes and a few other technical features), you are still creating objects (scripts) that perform actions and can be referenced by other scripts. You needn't be scared off by these technical sounding terms. Developing a FileMaker Prosolution requires only a fraction of the time, yet the results are similar to developing with a programming language.
2.2 Understanding the Macro functionality of ScriptMaker
The best approach to creating a script is to list out the steps of the procedure in plain English. A good example is finding and printing all delinquent payments for an invoicing system. The steps in a script are similar to those you would use if performing the task manually. You might find yourself doing the following:
Sending delinquent notices
In real life...
Steps you might take to send out notifications of delinquent payments.
- Step 1. Find all the invoices that are past due.
Step 2. Print out each invoice, stopping when you reach the last delinquent invoice.
Step 3. Make a notation that a second invoice was sent to the customer.
Step 4. File the original invoices.
This four-step process is a simple task once the steps are broken down. These steps just need to be translated into the ScriptMaker language. ScriptMaker uses a linear process much like you would. ScriptMaker starts at the beginning and steps through each script step until it comes to the end of the script or until something tells it to stop. (Either a Halt or Exit script step will stop a script prematurely; both will be covered in a later chapter.)
Sending delinquent notices
ScriptMaker script: "Delinquent Notice"
This is an example script, written in English, that finds all delinquent invoices and prints a notice for each one.
- Step 1: Find [Restore] a find that locates all past due invoices
- Step 2: Go to the first record
- Step 3: Go to layout formatted to print invoices
- Step 4: Begin Loop (Repeat the printing process until all invoices are printed.
- Steps 5,6, and 7 comprise the loop.)
- Step 5: Print the invoice
- Step 6: Make a note on the current invoice that this is the second notice
- Step 7: Go to the next invoice (record) [Exit the loop if it is the last invoice, otherwise go to Step 5 and loop again]
- Step 8: End Loop
- Step 9: Go back to the original layout
- Step 2: Go to the first record
2.3 How powerful is it?
You can do anything with FileMaker Pro that you can do with a calculator or even a paper and pencil. The advantages of using a database are speed and automation of repetitive tasks. Calculation fields, along with the Find and Sort mechanisms, provide the speed. They evaluate and arrange data more quickly and easily than by any other means. Using ScriptMaker adds a level of automation and sophistication to your database, making it significantly more useful. Sequencing the steps which perform Finds and Sorts, adding repetitive controls (looping) and incorporating the power of decision-making conditional statements (ifthen-else), enable your database to do just about anything you can dream up. By attaching the script to a button, the whole process becomes a one-click operation.
2.4 The real learning curve
Mastering ScriptMaker is like learning to play a musical instrument. The more you practice, the more you will be able to determine when and how to use this new skill. When working with FileMaker Pro you should always ask yourself the following questions:
Key questions when using ScriptMaker
Things to ask about your database
- Would it be faster if the computer did this?
- Am I repeating steps that could be automated?
- Are there too many steps for another person to remember if I told them how to do it?
- Can I simplify the process?
With the information in this book, you set your own learning curve. This book, plus the companion CD, will give you everything that we've ever come across in the life of FileMaker Pro. Beyond that, it's a simple matter of taking the time to understand how ScriptMaker can work for you. Examine your own use of FileMaker Pro. If there is something you are doing manually on a routine basis, it can be automated. If it's taking too much time to step through a certain procedure, you can optimize it. The time invested up front in programming ScriptMaker will pay off handsomely in the long run.
What you should have learned
- What ScriptMaker is and does
- How breaking down the events of a process can lead to automation
- Working with ScriptMaker is the only way to learn