Guest databases are an incredibly powerful feature that was quietly built into Frontier 5. The feature suffered from some memory issues in 5.0, which were improved in 5.0.1 and should be ready for full deployment in the next release. If you want to experiment before 5.0.2 you should be running the latest beta and root update which you can get here.
What is a guest database?
A guest database is a Frontier ODB file (.root file) which lacks a system table, and is opened as a document. Your main root (Frontier.root) is then refered to as the 'host' database.
You can think of a guest database as an special table in your root, which lives in its own file. The guest database becomes part of your environment root environment and is accessed similar to file based objects above.
It is always useful to first get the path to your GDB in a variable.
local (GDB = "HD:files:myGDB.root")
Then you can access objects in that root with references like:
sizeOf ([GDB])
[GDB].aScript ("param1")
You access subtables of this root in a similar way:
msg (nameOf ([GDB].subTable.subTable.anItem))
When you run a script that lives in a guest database - it runs in the context of the host root. For example if you have a script in the GDB that has a line:
msg (scratchpad.tempValue)
It will display the value that is in the scratchpad table of your frontier.root file, even if the GDB also has a scratchpad table defined.
If you want to write a script that knows where it is being run from, use the 'this' special variable in combination with the parentOf verb.
Once you have the address of an object that is in a GDB, all Frontier verbs should act on that object just as if it were in your frontier.root file. This is a big advantage of using Guest Databases over the db.* verbs.
Applications:
There are many advanced applications for GDBs. One might imagine a day when the entire user table might be its own GDB making upgrades much easier.
Many people may want to try managing a website that is in its own GDB.
To do this follow these steps:
- First create a new blank database by selecting "File -> New -> Database"
- Give the database a Name and save it to your hard drive
- Select the "Web -> New Website..." menu item and give the site a name
- Open up the websites table, then open up your new website.
- Select everything in the new empty website, copy, and then paste into the blank GDB.
- Save the GDB.
- You may now wish to save the GDB and make copies of it to use as a template.
Thats it!
Enjoy exploring these new dimensions - please send me any comments or corrections.
Preston Holmes
Page 1: Standard file based objects
Page 2: Guest Databases