.Initializeto the database and put the code there. Panorama will automatically run this code every time the database opens (with one exception – it will not run if the database is opened without any windows, using the opensecret statement). You can use this procedure to initialize variables, set up custom menus, pre-sort or pre-select the database… any task that needs to be done automatically whenever the database file is opened.
Keep in mind that you can’t know in advance what window will be open when the
.Initialize procedure runs. If you’re just initializing variables or menus it doesn’t really matter, but if your initialize code requires a particular form or window to be open, the code should explicitly make sure the needed window is open, using either the window, openform and/or opensheet statement.
If a procedure is already running when a database is opened (for example if a procedure uses an opendatabase statement to open another database), the original procedure will pause until the
.Initialize code is finished, then resume from where it left off. Because of this, it’s best to keep the code in the
.Initialize procedure as minimal as possible. Just do the minimum necessary. We’ve seen very complicated
.Initialize procedures that open dialogs, alerts and/or forms, completely changing the experience of opening a database. We recommend avoiding this kind of complication and just stick to the minimum code and disruption needed.
Note: In Panorama X 10.0 and 10.1, Panorama did NOT pause the original procedure to run the
.Initialize procedure. Instead, the
.Initialize code would not run until the the original procedure was finished. This could be confusing if a procedure opened several other databases. Starting with Panorama X 10.2, the
.Initialize code runs immediately when a database opens, and the original procedure (if any) must wait to complete.
If there is an error in the
.Initialize code, Panorama does not display an alert or open the Error Wizard. Instead, it simply displays the error in the Notification Center (in the upper right hand corner of the screen). If you don’t have Notification Center enabled, you won’t see the error message.
Before Panorama X 10.2, a common application for the
.Initialize code was to automatically open other databases needed to work with the current database, for example an Invoice database could open 4 other databases it needs by using code like this:
opendatabase "Inventory" opendatabase "Prices" opendatabase "Customers" opendatabase "Sales Staff"
In Panorama X 10.2 or later, you can remove this code, and use the Auxiliary panel of the Database Options dialog to specify that these databases be loaded automatically – no code needed at all. See Auxiliary Databases to learn more.
If you want to open a database without running the
.Initialize procedure (for example if there is a problem with the
.Initialize procedure), use diagnostic mode. See Opening a Database in Diagnostic Mode to learn how this mode works.
|10.2||Updated||Altered control flow so that .Initialize code runs immediately when database opens. If the database was opened with a procedure statement, the code in .Initialize will finish before the original procedure resumes.|
|10.0||Updated||Carried over from Panorama 6.0.|