Sometimes a script will fail with no apparent cause.  The usual course of action is to check the log window, but sometimes there is just silence – an empty trail with no leads to follow.  But there is a another source of information, the global variable exception_msg.

This is the scenario I am dealing with at the moment.  I have a table open.  When it closes some actions need to be performed.  I perform those actions by associating a script to the On Close event.  But the script fails.  Silently.  By inserting some show messages I track down the problem to a line of code:

Where Current Data Source is a function that I have defined.  The function is in scope because I have an include statement as part of the on close event handler.

To utilise the exception message I can bracket the statement within a Try block:

Here is the message I get in the log window:

My user-defined function accesses data within a namespace.  The reference to the namespace is obtained by calling another user-defined function Get Project Path Namespace.  This function is out of scope; I need an additional include statement within the event handler – problem solved.

Share the joy:

Leave a Reply