We've done a lot of work to make Frontier easier for people with an AppleScript background. It's simpler now, because you can continue to use the AppleScript editing and debugging tools you already know. And we've moved many of the barriers out of the way.
This page has all the information you need to start working in Frontier. When and if you're ready for more, there are links that show you how to dive in deeper. But if you stay just with the features on this page, you will get many of the benefits listed in the following section.
Why run AppleScripts in Frontier?
- AppleScripts can access Frontier's full verb set. Think of Frontier as a giant collection of debugged and documented and compatible OSAXen. Unlike many packages of OSAXen, Frontier is free. So you can install the runtime system in one simple operation and at no additional cost.
- Since Frontier is a fully PowerPC native environment, all its built-in verbs are also native. That means that text and other CPU-intensive operations run much faster on newer machines; up to 45 times faster. It's a major difference for web applications that process lots of text.
- AppleScripts can access data stored in Frontier's object database. It's fully native too, unlike the Macintosh OS. This can mean dramatically improved performance for scripts that assemble text and data from lots of different sources.
- AppleScripts are integrated into Frontier website building features. Macros can be written in AppleScript. Dynamic pages can be built by AppleScripts.
- Your scripts run in a multithreaded environment. This is especially important for CGI scripts running behind a web server such as WebStar. Frontier is the only environment that allows fully threaded AppleScript CGI execution.
Getting Started
Launch Frontier. Enter your name, organization and initials into the customization dialog. Click on OK.
Open the Workspace table by choosing Workspace from Frontier's Open menu. You'll see a single script in that table, entitled hello:
To open the script, press Command-Enter or double-click on the triangle to the left of the hello cell. A script window opens:
Click in the run button and a Hello World dialog appears.
Creating a new script
Choose the New Script command from the Main menu. A dialog appears:
Choose Workspace script from the Kind popup, AppleScript from the Language popup, and enter the name test, and click on OK. A script window opens. Enter a simple six-line script:
The first line is a comment. Enter the line and then choose Toggle Comment from the Script menu in Frontier's menu bar. This menu only appears when a script window is frontmost. As you would expect, comment lines are not processed by the compiler.
This second line reads an object database location in the user table called name, and copies it to a local variable named username. Then the script displays a dialog asking for the user's name, copies the result back into a local, and then stores the result in the object database. The next time you run the script it will reflect the new value.
Now would be a good time to save changes. To do so, simply choose Save from The File Menu.
To run the script, click on the Run button in the window. You may get a syntax error, if so, an error info window will appear:
If you click on the Go To button in this window, it will take you to the line that contained the error.
Scripts calling other scripts
One of the advantages of storing your AppleScripts in the workspace table is that you can easily build libraries of re-usable scripts. Let's build such a script.
Create a new script called circumference in the workspace table using the New Script command in the Main menu, as described above.
Enter the script as below, using the Return key to create a new line; using the Tab key to indent, and shift-Tab to outdent:
The script has now become part of the vocabulary of all scripts running in the Frontier environment.
You can call it from any other script by saying workspace.circumference (12), for example.
You can try it out from Frontier's Quick Script window. Choose Quick Script from the Open Menu, type the text as shown below, and click on the Run button.
You can call this script from any other script that runs in the Frontier environment.
When you see a call to a script and want to jump to its definition, hold down the Command key and double-click on its name. Frontier will open the window containing the definition of the script. This can help you figure out what a script does.
Built-in verbs
Frontier has a lot of built-in verbs, and you can call any of them from your AppleScripts. Basically, if the Macintosh Operating System has a way of doing something, we usually have a simplified interface accessible thru Frontier.
To see a list of all the verbs in Frontier, choose Verb List from the Open menu. A window opens:
If you want to see a definition of any of these verbs, hold down the Control key while double-clicking on its name. Frontier automatically launches the DocServer application and opens a page describing the verb:
You can also get an idea of how to use Frontier's built-in verbs from reading scripts on the "Samples Website".
Editing scripts
Even though Frontier's built-in script editor offers the advantage of outline-oriented script editing for AppleScripts, we can't offer debugging features for AppleScripts, and we don't have any way of browsing AppleScript terminology resources.
Fortunately there are several AppleScript editors that solve these problems well, and even better, they support an Apple Event interface that allows them to edit scripts that live in other environments.
Here's how you do it with Late Night Software's Script Debugger:
- Click on the script in the workspace table to highlight it.
- Choose Edit with App from Frontier's Main menu.
- Choose the Script Debugger app from the standard file dialog. You'll only need to do this once, Frontier will remember the location of the editor.
- After you have debugged the script and are satisfied with the result, choose Save from Script Debugger's File menu. The changed script will be saved in its location in Frontier's object database.
Calls to Frontier built-in verbs will appear in |pipes|. This is because the AppleScript interpreter doesn't understand Frontier's dot syntax for object database cell addresses.
You don't need to use pipes when you're editing the scripts in Frontier, because we automatically insert them for you. Script Debugger doesn't do this, so you'll see the pipes there, and when you save the scripts into Frontier the pipes will still be there. The scripts will still run correctly.
To edit the script in Frontier, check out "Chapter 7" of the User's Guide. It explains how to use the script editor. Or read the "Outliner Crib-Sheet" page which gives you a quick overview of Frontier's outliner script editor.
The AppleScripts sub-menu
Check out the AppleScripts sub-menu of Frontier's Main menu. It contains three commands:
- Load AppleScript... presents a standard file dialog that allows you to choose an AppleScript file to load into Frontier's object database. The script is loaded into the Workspace table in Frontier.
- Load a Folder... presents a dialog allowing you to choose a folder. All the AppleScript files in the folder are loaded into a sub-table of the Workspace table.
- Load an OSAX... presents a standard file dialog that allows you to choose a Scripting Addition file. It's loaded into the system.extensions table in Frontier. Before loading an OSAX, be sure the name of the file is an "identifier", meaning that its name contains no blanks, and only contains alphabetic and numeric characters.
This command is necessary if you want to call an OSAX function from a UserTalk script. AppleScripts running in Frontier can access OSAXes in the usual way, type the name of the verb and parameters as you would in any other script editor.
Other places to add scripts
You can write agent scripts that run in the background, scripts that run when Frontier starts up and shuts down, you can add scripts to Frontier's menu bar, CGI scripts that run behind a web server, scripts that run in response to an incoming Apple Event, scripts that run every hour on the hour, or every night at 2AM. All these options are available from the New Script dialog, discussed above.
Workspace and beyond
The workplace table is a nice sandbox for learning how Frontier can make your AppleScripts more powerful and run more quickly. When you're ready to branch out, let Frontier's built-in Navigators guide you thru the other features of the Frontier system. Here's what a Navigator looks like:
When you choose an item from the popup menu in a Navigator window, the explanation changes. When you click on Go There, the table opens. The Navigator window stays open. More information is at The Importance of Navigators page.
Where to go
When you're ready for more Frontier, check out the Explorer's Guide to Frontier, the second chapter of the Frontier User's Guide.
For more information on editing scripts with Script Debugger, check out the "Editing AppleScripts using Script Debugger" page.
Mason Hale wrote an essay shortly after switching from AppleScript to Frontier's built-in UserTalk language. It's an interesting perspective for anyone who's hitting the power limits on AppleScript's runtime environment. See "Mason compares AppleScript and Frontier".
For more info on the Open Scripting Architecture, see the "UserTalk Everywhere" page.
© Copyright 1996-98 UserLand Software. This page was last built on 5/9/98; 8:31:32 AM.
It was originally posted on 9/27/96; 4:05:43 AM.