Debugging scripts (FileMaker Pro Advanced)
The Script Debugger is an interactive tool for troubleshooting your FileMaker
scripts.
With the Script Debugger, you can:
•debug scripts that are run from the Scripts menu or keyboard shortcuts
•debug startup scripts (the Script Debugger menu is enabled even if there are no open files)
•step into a
sub-script to execute it one step at a time, or step out of a sub-script
•set or clear breakpoints in your script
•view sub-scripts as you step through scripts
•debug restricted-access scripts
•pause a script when script errors are encountered
•temporarily disable or enable script triggers while you work in the Script Debugger
To debug scripts:
1. Enable the Script Debugger by doing one of the following:
•Choose Tools menu > Script Debugger, then run your script.
•Choose
Scripts menu >
Script Workspace, select your script, then click
. To save all open scripts and then debug the script, hold down Shift (Windows) or Option (OS X) and click
.
2. Use these controls to debug the script:
Choose | To |
Step Over | Execute the script one step at a time without entering sub-scripts. If the script step is Perform Script, the Script Debugger will execute the sub-script, and proceed to the next line of the calling script. The Script Debugger will execute all sub-script steps until it encounters a breakpoint. |
Step Into | Execute the script one step at a time, as well as enter and show steps in sub-scripts. If the script step is Perform Script, the Script Debugger will step to the first line of the sub-script and wait for user input before proceeding to the next sub-script step. |
Step Out | Execute all script steps in the current script and, if the script is a sub-script, return to the line after the Perform Script step in the calling script. If the script is not a sub-script, the Step Out command will cause the Script Debugger to execute all remaining script and sub-script steps until it encounters a breakpoint. |
Set Next Step | Set the step execution pointer to the highlighted script step. This command passes control to the highlighted step but does not perform the step. The highlighted step is performed when script execution or debug stepping is resumed. Any script steps between the last executed step and the assigned next step are not executed. Click a step to highlight it, then click . |
Run Pause | Toggle between executing all script steps until the end of a script or a breakpoint is encountered and pausing. When a script is paused, you can double-click the script in the Call Stack list to edit it. Each active script opens in a separate tab in the Script Workspace, so you can edit multiple scripts. Script execution is not halted until you save the changes. You can step through a script using when a script is paused. |
Halt Script | Halt execution of a script. |
Enable/Disable Script Triggers | Temporarily disable or enable all script triggers in a file. You must have Full Access privileges to disable a script trigger. Script triggers are enabled by default. When you close the Script Debugger, all disabled script triggers are enabled. |
Edit Script | Opens the current script in the Edit Script dialog box. You can make changes to a script while it is executing, but once you save changes to the script, execution halts. |
Open/Close Data Viewer | |
Authenticate/Deauthenticate script | Unlock the Script Debugger or Data Viewer for scripts that do not allow modify privileges. You must have Full Access privileges to authenticate a script. The higher level of privileges applies to all scripts, but not to other file elements (for example, records and layouts). Your editing privileges last until you close both the Script Debugger and the Data Viewer. |
3. Select Pause on error if you want scripts to pause when errors are encountered.
Viewing sub-scripts
You can view sub-scripts when you step through scripts in the Script Debugger. For example, if Script A calls Script B, which then calls Script C, you can view the steps in all three scripts.
1. Choose Tools menu > Script Debugger.
2. Perform a script that calls a sub-script.
3. Click Step Into.
The Call Stack list displays the sub-script.
4. Select a script in the Call Stack list to view that script’s steps in the display area.
Notes
•To set or clear a breakpoint, click the line number to the left of the script step. Breakpoints allow the Script Debugger to execute large sections of a script, pausing only to inspect the section marked with a breakpoint. Breakpoints are ignored by FileMaker Pro when the Script Debugger is not in use. You can set breakpoints on multiple steps. You cannot set breakpoints on steps called by a button or custom menu.
•In order to facilitate proper script debugging, the Script Debugger overrides some script steps. The Allow User Abort script step with the option set to off will not prevent you from stopping the execution of a script. The Adjust Window script step with the options of hide or minimize will not hide or minimize the window when encountered through the Step Over
or Step Into
buttons.
•If a script with access privileges set to Modifiable performs a script with Executable Only access, the executable only script will perform in its entirety without showing its steps in the Script Debugger. If an executable only script performs a script with privileges set to Modifiable, only the steps in the Modifiable script will appear in the Script Debugger. To edit a script, click
in the Script Debugger. For more information about script privileges and running scripts with full access, see
Editing scripts privileges.
If you open the Data Viewer after clicking
, your access privileges are maintained in both the Data Viewer and Script Debugger until you close the Script Debugger.
•You can debug a startup script by opening the Script Debugger before opening your database file.
•When you close the Script Debugger while a script is paused, the script resumes and completes.
Related topics