Database Reference
In-Depth Information
words, the window stays open long enough to run the script you've specified and t hen it
closes. Your database's last window is closed if you quit FileMaker or if you manually close
all its open windows. However your database may stay open even if you've manually closed
all its windows; when another database uses one or more of your database's tables in a rela-
tionship, FileMaker keeps your database open as long as it's needed by that other file. If
FileMaker keeps a database open, OnLastWindowClose runs each time you close your data-
base's last open window.
So now that you've worked through all that logic about when a window is open and when
your database is open, why would you want to use an OnLastWindowClose script? You
might want to do housekeeping chores like finding and marking incomplete records so an
OnFirstOpenWindow script can find them for you the next day.
NOTE
Exactly when a script trigger is fired is very important because it means your script can cancel the
action that triggered it. You can use an Exit Script step ( Halt Script and Exit Script ) to check a
condition that keeps your database from closing. For example, if you forgot to run the credit card for
your last invoice, Exit Script could return a False, which would cancel the closing of that last
window. The database stays open so you can finish the job.
OnWindowOpen
OnWindowOpen runs every time a new window is opened in a database. It doesn't matter if a
script opens the window or you do it manually (Window→New Window). The script you as-
sign to this trigger runs every single time, no matter what context the window is opened to.
As with OnFirstWindowOpen , this trigger runs before its window enters a mode. Because the
script would need to be free of context (you might open a window for the Customer, Job, or
Invoice layout) and will be run frequently while you're working, this trigger is not com-
monly used. But it can be used in combination with OnFirstWindowOpen , which runs first,
OnWindowOpen will run. And if that first window opens to a layout that also has a trigger, you
can start a little Niagara Falls of scripts running to get your database all lined up and in
marching order.
OnWindowClose
OnWindowClose shares behavior with the other members of this trigger family. Like its sister
trigger, OnWindowClose runs every time a new window is closed in a database. And like
OnLastWindowClose , the trigger runs its script just before the window actually closes.
Search WWH ::




Custom Search