Frontier's built-in storage system is called the object database. It can store small objects like a user's name, the time of the last backup, or larger objects like a list of users, a standard form letter, or a table of electronic mail accounts.
The object database makes it easy for scripts to communicate with each other, to share data, and since the database can store scripts too, you can build foundations, re-use your code, solve a problem once and build up from there.
An example of a foundation is the CGI Framework, described on the CGI Scripting in Frontier page on this site. It defines a simple scripting environment for writing multithreaded CGI scripts.
You can use the object database to store an entire website, giving you a very powerful framework for object oriented websites, using templates, macros, glossaries, and connections to standard apps. See the web scripting tutorial for more information.
The object database is stored in a file called Frontier.root. It must be in the same folder as the UserLand Frontier application. Frontier.root contains a single table called root.
To open the root table, launch Frontier, bring the main window to the front, flip down the flag, and click on the Object DB button.
Figure 1: Frontier's main window with its flag flipped down.
Here's what the root table looks like:
Figure 2: The root table with the cursor on the readme cell.
To open a sub-table, double-click on the black wedge next to its name. You can also type cmd-Enter to open a sub-table. Any item that can open in a window can be opened this way, including pictures, outlines, scripts and menu bars.
Object database values can be small things like booleans, characters and numbers; or large things like strings, word processing text, outlines or scripts. Frontier supports over 20 built-in types, and has a general type called "binary" which allows you to store types which Frontier doesn't directly support.
Browse the examples table to see examples of many of the different kinds of values that Frontier can store.
The Kind popup menu, at the bottom of each table window, allows you to change the type of an object. Some type coercions are not possible, those types are gray in the Kind poupup.
The Sort popup allows you to change the order in which objects are displayed in the window.
From scripts, you use dot-syntax to traverse the table hierarchy. For example, to add 1 to the number "age" stored in the scratchpad table you say scratchpad.age = scratchpad.age + 1. You could also say scratchpad.age++.
The object database uses a 31-bit internal address, so files can be huge, usually limited only by available disk space. Even though the database is disk-based, Frontier has a Save command, and even a Revert command, allowing you to roll back to the previous version of the database.
You should usually save your changes when quitting Frontier. Quitting without saving changes is a very rare thing, it's pretty hard to know what changes you'll be living without if you choose not to save changes before quitting.
Because database paths can get long, UserTalk has a "with" statement, like Pascal's, that lets you easily work with deeply-nested tables.
Frontier has another mechanism to help simplify deeply nested values, the paths table, at system.misc.paths. Like Unix or MS-DOS, the paths table defines a set of object database tables that are globally accessible.
Another special table is system.agents. Any script in system.agents is executed once per second. Agent scripts are used to monitor folders, especially on shared disks. A server running Frontier can run an agent script that watches the folder. When a file appears in the special folder, the agent script processes it in some fashion.
In addition to agent scripts, there are special tables for scripts that run on startup and shutdown and scripts that respond to incoming Apple Event messages. Even the interpreter's runtime stack is accessible thru the object database hierarchy.
Much of the culture of Frontier is implemented as scripts stored in the object database, so you can examine and customize the scripts and add your own. When we upgrade Frontier, we only upgrade the parts of the database that we created, and leave the parts that are subject to customization untouched.
Adding new objects
To add a new cell to a table, you can:
- Choose a command from the Table menu;
- Open the table's window and press cmd-Enter, enter the cell's name, tab over to the Value column, enter a value, then press Enter.
- Use the new verb in a script; or
- Assign a value to it from a script, especially from the Quick Script window.
The Directory page points to all Frontier-related websites.
Chapter 6 of the Frontier User's Guide.
Nerd's Guide to Frontier -- A description of Frontier for experienced C and Pascal developers.
Nerd's Guide to this Website page for the DaveNet website.
© Copyright 1996-97 UserLand Software. This page was last built on 6/3/97; 8:16:26 AM.
It was originally posted on 5/6/96; 9:11:21 PM.
Internet service provided by Conxion.