saveandclose
DATABASE
,
DELAY

The saveandclose statement saves and closes a database file.


Parameters

This statement has two parameters:

database – name of the database you want to save and close (or "" to close the current database).

delay – delay before the database is closed (if this parameter is omitted, the default is 3 seconds).


Description

This statement saves and then closes a database file. This is recommended instead of performing these operations with separate consecutive statements. So instead of this:

save
closefile

the recommended code is:

saveandclose ""

You can also save and close a database that is not currently the topmost database, or even a database that doesn’t have any windows open.

saveandclose "Price List"

Technical Note: Panorama uses Apple’s NSDocument framework to manage database operations, including saving the database. When you save a database, NSDocument performs this operation asynchronously. This means that it will save in the background, while your procedure continues on with the next task. If the next task is closing the database, this can cause problems because the document will close before the save is complete.

To solve this problem, the saveandclose statement performs this sequence of steps.

In other words, the database will appear to close immediately, but it isn’t actually removed from RAM for 5 seconds. This gives the save operation time to complete. You can also add a second parameter to adjust the time delay, for example this code will use a delay of 10 seconds.

saveandclose "",10

However, I wouldn’t recommend making the time too long. For example, suppose you made it 60 seconds, but then 20 seconds after running this statement you opened the database again. You’ll probably be surprised when the database closes again 40 seconds later!

Keep in mind that Panorama uses a timer to remove the database from memory, so the specified delay is the minimum time. It could be longer. For example, if you use saveandclose and then the procedure continues to do further processing for an additional 30 seconds, the database won’t actually be removed from memory until after all of that processing is complete.


See Also


History

VersionStatusNotes
10.2NewNew in this version.