closeserverfile

The closeserverfile statement closes the current database (used on the server).


Parameters

No parameters.


Description

This statement tells Panorama X server that the current database can be closed. It can be used by web publishing code that has used the openserverfile statement to open a database.

The closeserverfile statement does not close the database immediately. First, it checks to see if any user has the database open for sharing. If they do, the file will not be closed.

If no one is using the file for sharing, it still will not be closed immediately. Instead, the server will delay before actually closing the database. The delay time is controlled by the Auto Close Delay option in the Server panel of the PanoramaX>Preferences dialog.

The purpose of this delay is server performance. If the database is opened again soon, Panorama won’t have to read the file from disk into memory again.

For example, here’s a web procedure for a very simple order entry database (so simple that each invoice can have only 1 item). This code adds a new order and looks up the price of the item.

let sku = webformitemvalue("SKU")
let wasDatabase = info("databasename")
openserverfile "Prices"
setactivedatabase wasDatabase
addrecord
SKU = sku
Price = lookup("Prices","SKU","SKU","Price",0)
setactivedatabase "Prices"
closeserverfile

If this web procedure is called multiple times within a short period (the Auto Close Delay period), the Prices database will only be read from disk into memory once. As long as the auto close delay period doesn’t expire, the database won’t actually close.

Note that the delay is extended each time this code runs. Suppose the Auto Close Delay period is 5 seconds. If the code is called once every 3 seconds, the database will never close. Each time the closeserverfile statement runs, the delay will extend another five seconds.


See Also


History

VersionStatusNotes
10.2UpdatedCarried over from Panorama 6.0.