The opensecret statement opens a database invisibly, without opening its windows.
Parameters
This statement has one parameter:database – identifies the database you want to open. If the database is not in the same folder as the current database, you must specify the entire path name in addition to the file name.
Description
The opensecret statement opens a database without opening any windows or launching the .Initialize
procedure. It’s useful if a procedure needs to access a database, but the user doesn’t need to see what’s inside.
This example opens a database called Shipping Rates, but does not open any of the windows for that database. It then looks up a rate from the table.
opensecret "Shipping Rates"
Shipping= lookup("Shipping Rates",Zone,Zip[1,3],Rate,0,0)
A database which has been opened secretly with the opensecret statement is not immediately active. It can be made so with the setactivedatabase statement, as in:
opensecret "Income"
setactivedatabase "Income"
Another way is to use the window statement like this:
opensecret "Income"
window "Income:secret"
It then remains the active database until the procedure ends, until another setactivedatabase statement activates another database or until the visible window changes, such as when a message or alert is triggered. The use of the save statement has the same effect but saves the database with no windows open. A consequence of this is that, if you subsequently attempt to open the database in the same procedure, it won’t open. The following code will overcome that problem.
opensecret "Income"
setactivedatabase "Income"
... do stuff in "Income"
save
setactivedatabase "Income"
opensheet
openfile "Income"
You could use an openform statement instead of the opensheet statement.
To make a database visible which has been opened secretly, displaying the windows open when it was last saved, use the opensavedwindows statament:
opensecret "Income"
... do stuff in "Income" with no windows open
opensavedwindows
... saved windows of "Income" are now visible
Unlike the opendatabase and openfile statements, Panorama does not automatically run the .Initialize
procedure when you use the opensecret statement (see Custom Database Initialization). If you want to run this procedure, you must explicitly call it in your program, like this:
opensecret "Income"
setactivedatabase "Income"
call .Initialize
As shown in this code, you must set the active database before calling the .Initialize
procedure, since the newly opened database doesn’t have any visible windows. Make sure that your .Initialize
code doesn’t rely on a window being open.
See Also
History
Version | Status | Notes |
10.0 | No Change | Carried over from Panorama 6.0. |