frondoc picture
What is Frontier?
Download
News & Updates
Mailing Lists
Sample Scripts
DocServer
The Finder
Search
Guestbook
Site Outline
BBS
User's Guide
1 2 3 4 5 6
7 8 9 10 11
Apple File Edit
Main Open Suites
Web Window
Menubar Outline
Script Table WP

Frontier website on www.scripting.com

Scripting Verona from Frontier

By Wesley Felter, wesf@mail.utexas.edu.

Verona is a flat-file database that is accessed using Apple Events. It is similar in many respects to FileMaker Pro, but is simpler and often faster. Unlike FileMaker, Verona is designed specifically to be scripted; there is no other interface. Think of it as "uBase on steroids".

One important aspect of scripting Verona is the fact that all operations are atomic and are handled by a single Apple Event, so no semaphores or transactions are required. Multiple threads can access Verona databases at the same time and it will sort out the details internally. Like FileMaker, all changes to a database are immediate and irreversible; there is no "commit" command. You will still need to use semaphores if you want to ensure that the database doesn't get changed between two calls.

A Verona database consists of records; each record has a structure defined by fields. Fields have references, names, types, lengths and values. A field is either indexed or unindexed. A field's reference is a string4, and its name is a string. When accessing a database, references are used to refer to fields. Every field has a defined length; the content of a record cannot exceed the lengths specified for each of the fields. The types supported are text, signed integers, unsigned integers, floating-point numbers, dates, and times. Currently, Verona database fields must be located in Verona's "Databases" folder; this means you can access databases unambiguously by name instead of having to deal with pathnames.


The "people" database as seen in VeronaTools

Searching and adding

Searching a Verona database is easy. The main script used to get data is verona.retrieve ( database, field, compare-value, compare-op, case sensitivity, return-fields, sort-by, start-with, max-hits, appID). This script searches, sorts, and returns specific records from the found set. Here's a sample that would search the above database:

verona.retrieve ("people", 'name', "Wes", "contains", false, [Macro error: Can't compile this script because of a syntax error.] , "name", 0, 20)

This script searches the database "people" for all records whose 'name' field contains "Wes" (case insensitive), sorts them by the 'name' field, and returns just the fields 'name' and 'URL '. It only returns 20 records that matched the search, starting at record 0. When searching, both the field that is being searched and the field that is being sorted by should be indexed for best performance. The result is a list of lists:


Searching the "people" database

The other important operation is adding records. This is done with the verona.addRecordToDatabase (database, withFields) script. Here's a sample:

verona.addRecordToDatabase ("people", [Macro error: Can't compile this script because of a syntax error.] )

The first parameter is the name of the database, and the second parameter is a list of name-value pairs. This script returns the unique index of the new record.

Other features

You can also get one record by passing its unique index to verona.getRecord (), and you can change the contents of a record with verona.setRecord (). Verona.lookup () takes the same parameters as retrieve (), but instead of returning actual data, it returns a list of unique indexes to the found records. You can then use getRecord () to get the data from individual records. Another useful verb is countMatching (), which takes the same parameters as retrieve () and lookup () but returns only the number of records that match the query. Doing a countMatching () is often 10 times faster than a lookup (), which can be another order of magnitude faster than retreive (). Verona is very fast, but it expects you to know what you're doing.

Most of Verona's other verbs are used for creating and modifying the structure of databases; in many cases it's easier to use VeronaTools for this. (VeronaTools actually uses these calls; it's just a FaceSpan application. But VeronaTools can only edit the structure of databases, not their data; if you want to know what's in a database, you have to use Frontier or WebSiphon.) For examples of these functions, see verona.examples.oneLiners.

Network support

Unlike FileMaker, Verona is network-ready out of the box. All of the verbs in its glue table take an optional last parameter which is the target of the verb. This can be a creator code (usually 'nøva'), a pathname, or a 'targ' returned by sys.browseNetwork (). Verona can handle at least 10 clients simultaneously searching and modifying the same database over a network; I personally tested this at WebEdge IV and it didn't start to slow down.


© Copyright 1996-97 UserLand Software. This page was originally posted on 3/2/97; 11:04:40 AM; It was last built on 3/2/97; 11:07:19 AM with Frontier. Thanks for checking it out! Dave