From Dwayne Wright PMP
Certified FileMaker Developer
Please Note: If you are viewing this page in a news feeder, the images may get munged up a bit or other formatting of the posting may fail. For the best experience, please visit the journal directly by clicking (here).
Early versions of FileMaker didn’t have a large selection of troubleshooting and debugging tools. FileMaker was easy to use, elegant and didn’t have any where near the complex design options it does today.
One of the great features of FileMaker Advanced, the Script Debugger allows you to step through script steps in a separate window to help identify where a script may be broken or might need some tweaking. The script debugger feature is available from under a Tools menu, along with options for the Data Viewer, Custom Menus, Database Design Report, Developer Utilities and File Maintenance.
QUICK OVERVIEW OF THE SCRIPT DEBUGGER
Called from the tools menu in FMP Advanced
Always on until you turn it off (and vice versa)
Allows the developer to step through a script line by line
Offers buttons to navigate next, previous, to a determined break point
Debugger can be used effectively with the Data Viewer
You can see interactions of a particular point and time within a script
You can step into subscripts or step out to calling scripts
Great if you have a lot of subscripts and branching actions
Jump directly from the debugger into the script and quickly edit it
So the way it works is that you activate the Script Debugger by choosing it from under the Tools menu. The debugger will appear in a new window but it will be empty. To fill it up, all you need to do is execute a script. As soon as you do that, you will see the script steps for that script show up and you are automatically placed on the first step.
So the idea is that you click one of the step button options to downward through the script and evaluate what is going on in the database at the same time.
With scripts that have a large amount of steps, you may want to jump right to a particular area of the script instead of stepping to it one step at a time. In the Script Debugger, you create a breakpoint where the script can run to and stop. Then you can resume stepping through the script one step at a time. So, the debugger allows you to put in breakpoints and you can quickly go past standard script events and get to what areas of the script you really want to evaluate. Breakpoints can be set while debugging or editing a script and are easy to add or remove. The breakpoints you set are saved along with the script, so they will be there when you want to debug that script again. Obviously, this is much faster than stepping through long scripts one at a time and it helps the developer to focus debugging on specific areas.
ABOUT SCRIPT PARAMETERS AND THE DEBUGGER
In FileMaker, you can have a button, a script or even a custom menu pass data (called a script parameter) to a script that it executes. So you can have two buttons that execute the same script but they can pass a different parameter to that script. Based upon what you pass via the parameter, that destination script will likely operate differently. The same is true for two scripts that both call upon the same subscript. You can view this parameter information in the bottom area of the script debugger.
DEBUGGER PAUSE ON ERROR
Using the FileMaker Advanced script debugger, if you have scripts with a large amount of steps, you may want to jump right to a particular area of the script instead of stepping to it one step at a time. This can be accomplished by setting breakpoints.
Another option you may want to explore is the “Pause On Error” checkbox that appears in the Script Debugger window. The selection of the Pause On Error checkbox in the script debugger will stop at the associated script step that caused the error condition.
This is kind of a dynamic breakpoint, again because the script will run to the point in which you encounter an error. A classic example is when an error message comes up that says you don’t have a valid relationship for a particular task your script wants to perform.
So if you encounter an error in the debugging process, you can then click the Edit Script button to jump directly from the debugger into the script and quickly edit it! Now this feature will work in scripts that have Set Error Capture [On] or those that do not.
© 2008 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.