|
|
SCRIPTING
Good Catch! Error Capture and Testing in FileMaker Pro Scripts
Learn how and when to use the Set Error Capture script step, and how to script comprehensive error testing and handling.
UNLOCKED -- This article is provided to subscribers of FILEMAKER ADVISOR or DATABASED ADVISOR or FILEMAKER ADVISOR. To subscribe or renew, go to Advisor Store.
PAGE 1 of 1 - 2 - 3 - » Next
It's a fact of life: Errors occur when using computer operating systems and applications. Fortunately, the majority of these are not fatal. With good programming, when errors occur, they're trapped and handled appropriately. When a serious error occurs, you may have to restart your computer. This is a good thing because the error handler is preventing further damage.

Figure 1: Which would you rather see? -- Standard FileMaker Pro error dialog and an alternate custom dialog giving more options to the user.
Errors also occur when using a FileMaker Pro database. These are often simple user errors such as entering the wrong data type into a date field or trying to modify a calculation field. When these errors occur, FileMaker Pro shows an alert message.
FileMaker Pro also displays alert messages asking youto confirm actions. For example, FileMaker Pro may ask if you're sure you really want to delete all 128,459 contact records from the database!
When scripting processes in FileMaker Pro, many developers like to handle the alert messages in a way different than the standard FileMaker Pro dialog. You can suppress standard dialogs using the Set Error Capture script step. This article looks at how Set Error Capture works, how best to use it, and how to test for and handle errors.
What is Set Error Capture?
Set Error Capture is a script step. It has one option: On or Off. "On" suppresses FileMaker Pro alert messages and some dialogs. "Off" re-enables the alert messages. You can check the status of the Get(LastError) function immediately after a script step to verify the step was performed properly.
It's interesting to read in the FileMaker Pro online Help that the script step "sends error handling information to the Get(LastError) function." It may be just semantics but errors are sent to the Get(LastError) function even if error capture is off. What is important is that you can test errors even if Set Error Capture is on.
It's also worth noting that Set Error Capture isn't Web compatible. When a script containing the script step runs via Instant or Custom Web Publishing, the Set Error Capture step is ignored. That may have consequences for how your scripts run via the Web.
What can I use Set Error Capture for?
The most common use of the script step is to let you suppress a standard FileMaker Pro dialog and present a custom dialog of your own that may:
- Make more sense to the user
- Provide more information about what went wrong and how to fix it
- Provide more options to the user
- All of the above
For example, compare the standard FileMaker Pro alert in figure 1 with the custom dialog alternative.
You can also handle errors automatically without informing the user, which is important if the error occurred without any user interaction. For example, consider a restored find in a script that finds today's orders. If there are no orders found, you can set the script to run an alternate report.
How persistent is Set Error Capture?
The persistence of a script step refers to how long it stays in effect. When you turn error capture on, it stays on for as long as the script (and sub-scripts called) run, or until you turn it off.
Let's look at an example. You have three scripts (A, B, and C):
Script A
...opening script steps...
Set Error Capture [On]
Perform Script ["B"]
Set Error Capture [Off]
Perform Script ["C"]
...various script steps...
Go to Layout [ original layout ]
Script B
Print [Restore]
Script C
...various script steps...
Set Error Capture [On]
...various script steps...
When you run Script A, it calls scripts B and C.
PAGE 1 of 1 - 2 - 3 - » Next
David Head, owner and principal trainer for uLearnIT, has been developing FileMaker Pro databases since 1993. In that time he has made, trapped, and handled a lot of errors. He is a FileMaker Certified Developer and a FileMaker Authorized Trainer. David has presented at FBA meetings and FileMaker seminars in Australia and New Zealand. In 2008, he will present a workshop at the FileMaker Developer Conference. As the Training Partner for FileMaker Inc., in the Asia Pacific region, uLearnIT offers FileMaker Pro training in Australia, New Zealand, Singapore, Malaysia, and Hong Kong. http://www.ulearnit.com.au david@ulearnit.com.au
Keyword Tags: FileMaker, FileMaker Development, FileMaker FileMaker Pro
ADVISORAMA A lawyer is a person who gets two people to strip for a fight, and then runs off with their clothes.
|
ARTICLE INFO
Web Edition: 2008 Week 19, Doc #19466Print Edition: June/July 2008, Page 6
ARTICLE LOCKED
|
FileMaker Advisor Sponsors
|

Read the advanced guide to creating custom business database solutions with FileMaker software. Subscribe now to gain access to all the archives and downloads.![]() 
Learn the fundamentals of using FileMaker Pro software. Every issue gives you step-by-step instructions on creating the databases you need. Subscribe now!![]()  ![]()
![]()

See exactly how to do it, step-by-step, in Advisor Academy CDs created by the top experts. Click to see what you can learn right now.![]() 
Keep up! Hot News, How-To, Tips & Tricks, Expert Advice, and more. Click to request your's free.![]()  ![]()

What direction are you going with your business? Advisor Guides are packed with the answers you need to work smarter. Can you afford to fall behind?![]() 
Submit your tips, techniques and advice and let Advisor promote your business and build your career. Show the world what you know!![]()  ![]()
|
|