The openfile statement opens a database file. It can also import data from a text file, another database, or a variable into the current database.
This statement has one parameter:
file – identifies the file you want to open. If the file is not in the same folder as the current database, you must specify the entire path name in addition to the file name, for example:
If this parameter begins with a + symbol, Panorama will append the contents of the file to the current database, with the first field appended to the first field, second field appended to second field, etc. If file begins with ++, Panorama will match the field names between the two databases as it appends the data. If a field name does not match, that field will not be appended.
If this parameter begins with a & symbol, Panorama will replace the data in the current database with the data in the file. The fields will be replaced in order, with the first field replacing the first field, second field replacing the second field, etc. If file begins with &&, Panorama will match the field names between the two databases as it replaces the data.
If this parameter begins with an @ symbol, Panorama will import from a variable instead of from a text file. For example,
"@mydata" tells Panorama to import from the variable mydata. This symbol may also be combined to append (
+@) or replace (
&@) the text from the variable.
Note: In Panorama 6 and earlier, the openfile statement was the primary method for opening databases and importing information. For compatibility with older databases, the openfile statement has been retained, but we recommend that for new applications you should use these newer statements:
These statements give you more control, and avoid tricks with the +, & and @ symbols.
The openfile statement can be used two ways: 1) It can open a database, 2) it can import into an existing database.
When used to open a database, the openfile statement loads the database into memory, opens the windows for the database and automatically calls the
.Initialize procedure (if any). If you don’t want the windows to open use the opensecret statement.
The example procedure below opens the price list and customer list databases (they must be in the same folder as the current database).
openfile "Price List" openfile "Customer List"
This procedure allows the user to select a TEXT file, then appends that text file to the current database.
local file,folder,type openfiledialog folder,file,type,"TEXT" if file="" stop /* the user pressed the CANCEL button */ endif openfile "+"+ folderpath( folder)+file
The example procedure below replaces the contents of the file Telemetry Data with the new data in Telemetry.TXT.
openfile "Telemetry Data" openfile "&Telemetry.TXT"
If the database contains a procedure named
.Initialize, that procedure will run before any code following the openfile statement. Essentially it is as if there was a call statement after the * openfile* statement, like this:
openfile "Mailing List" call .Initialize ... ... additional code ...
|10.0||Updated||Carried over from Panorama 6.0, but no longer allows HTML import, and no longer opens a file open dialog if the filename DIALOG is passed. When appending (or replacing) data from another database, that database must be open.|