Troubleshooting

 <  Day Day Up  >  

graphics/troubleshooting_icon.jpg

Lost Error Messages in Scripts

My script is not working properly, but I'm not getting any error messages. Where do I start?

Be sure that you properly account for potential errors if you turn error capture on. What if a find request returns zero records? What if a user doesn't have access to a given layout, which is needed for a script? To manage debugging, turn error capture off while you're testing. Some developers write scripts that toggle error capture for all scripts in a system. This is a convenient way to turn on and off a debugging mode.

Unfinished Scripts

I need a script to run to completion without fail. I set Allow User Abort [off], but it appears that the script was aborted at some point by a user. How can I make sure users can't muck with my scripts?

Remember that turning Allow User Abort off doesn't always save you from errors in the script itself, power outages, the user closing FileMaker Pro, or other random acts of unpredicted computer wonkiness. You can never absolutely depend on a script completing in FileMaker Pro. If need be, write a "check conditions" script in your system and run it when appropriate. Another way to deal with this problem is to write a script log that saves a record when a script starts and another when it ends. You can check for incomplete pairs.

Editing the Correct Related Records

My Set Field script step is just continually changing the first record in a portal instead of the one I want. How do I get the script to act on the proper row?

Be careful when setting fields through relationships. It's possible to think that you're pointing to a single record when you're really pointing to the first of many. In that case, FileMaker blithely applies your script steps to the first valid related record it finds. Either put a button directly in a portal ”in which case the script will apply to that row ”or use a Go To Related Record script step to explicitly control both the context and the record against which a script operates.

Conditional Error Defaults

My case statement isn't returning the proper result. How can I test what's going on?

Be sure to account for all variations of logic in your conditional scripts. It is strongly recommended that you build If routines that end with an option that you think will never occur. Here's a quick example:

 

 If [Invoices::Total > 0]     Do something Else If [Invoices::Total = 0]     Do something Else If [Invoices::Total < 0]     Do something Else     Handle error conditions here End 

This function should never return the default error but you cannot perfectly predict all such behaviors. For example, what if a calculation for Total is wrong and returns a null or empty value? Or perhaps a calculation you expect to be numeric returns text in some cases?

Testing Loops

My loop seems to be stuck endlessly looping. How do I debug the problem?

The rare developer gets everything right the first time, but if you don't, you might find yourself in the middle of an endless loop. A handy trick is to always create an exit condition that tests whether the Shift key is held down by using the Get( CurrentModifierKey ) function. It's a backdoor out of your loop that's quite handy if you have an error in logic. A much easier way to go if you own FileMaker Developer is to simply turn on the script debugger the first time you test a new loop.

 <  Day Day Up  >  


QUE CORPORATION - Using Filemaker pro X
QUE CORPORATION - Using Filemaker pro X
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 494

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net