UserLand Software
Powerful, cross-platform web scripting.
 

What Does Frontier Do?

Frontier Scripting Tutorial

About This Tutorial

What Does Frontier Do?

Keywords, Handlers, Verbs, and Calls

Loops, Variables, Parameters, and Conditionals

The Handler Rule

Returns, Addresses, and Dereferencing

Scope and With

Strings and Files

Outlines and Tables

Running, Debugging, and Getting Help

Datatypes

A Real-Life Problem

String Parsing and Substitution

Manipulating Files and Folders

Final Touches

You're the boss

When you buy an application for your computer -- let's say, a word-processing program -- you buy something that will make your life more convenient, to be sure, but you also buy your computer a new master.

When that word-processing program is running, it essentially takes over your computer; your computer becomes that program, working the way that program says, according to that program's particular abilities, commands, concepts, structures.

And in order to work with that program, you yourself have to fall into line with the program's way of doing things. In a way, you have bought yourself a new master too.

The philosophy behind Frontier is that the master of the computer should be you. Of course, if what you wanted to do is process words, a word-processing program is essential. But you should also be able to take advantage of the computer's power directly, yourself, to accomplish the particular tasks you have in mind.

What tasks?

What sorts of tasks might those be?

To put it another way: what is the power of the computer? A computer is good at three things:

Calculation

People tend to make mistakes when they have to calculate, and it can take them a long time. A computer can crunch numbers rapidly and with no errors at all. It can also crunch other things, such as text.

Suppose I have the HTML source for someone else's Web page I've downloaded, and I want a list of all the links to other URLs that it contains. I could just examine the HTML source (in a word-processor) and, by eye, look for <a> tags that contain an href.

But a computer can look for these much more quickly and accurately than I can (with a "Find" command, perhaps). That's text-crunching, a form of calculation.

Repetition

People get bored when they have to do the same thing over and over; it starts to feel like a waste of time, and mistakes creep in. Computers don't care; indeed, "looping" repeatedly through the same tasks is their natural mode of being.

Let's go back to my list of links in an HTML source file. Finding one URL, copying it, and pasting it into another document is an everyday, unobjectionable task. Doing it five times, though, is a bit wearisome, and doing it a hundred times would be horrendous.

To a computer, on the other hand, it's all the same. Increasing the size of the job may add to the time, but not to the difficulty, of the job.

Abstraction

People naturally tend to clump multiple things into single things. When I first learned to tie my shoes I had to think about each step: make a loop, go round the loop, go through the hole, pull both loops. Now I just think: tie my shoes.

Or I might abstract even further and think: get dressed. Abstraction is about isolating a chain of events into a single event that's meaningful as a whole to the human mind.

Computers can help with this. The more I can accomplish with a single command, the further back I can stand from the nitty-gritty, the more I can make my own actions be general and let the computer take care of the details, the better.

As the shoe-tying example shows, abstraction can occur without repetition (or, at least, without immediate repetition). It occurs any time you just don't want to be bothered with the details, especially when you think the details are stupid.

For instance, recall how, in the Finder, you can use Frontier to open an HTML file either with a text-editor or with the browser. If the file has the browser as its "creator", double-clicking it will open it in the browser; to open it in the text-editor, you'd need to open the text-editor first, then use the Open dialog in the text-editor to find and open the file.

Frontier abstracts this process; it performs it for you, effectively giving you a shortcut. You may scarcely ever use this feature, but when you do need it and it's there for you, it feels great, because people don't like having to turn something that feels like it ought to be one action back into multiple rote actions. You get to perform the action your way, instead of becoming a slave to the computer's way.

Abstraction piles on top of abstraction. In the list of links example, isolating the task is an abstraction. I have to find a URL. I look at what I do in order to find it; then I teach the computer how to do that.

Now the computer has a concept "find a URL." Now I abstract further: "find a URL and copy it to a list." Then, by introducing repetition, I abstract still further: "list all the URLs in this document."

With perhaps another level of repetition, I abstract still further: "list all the URLs in each document in this folder."

To these features, Frontier adds one more:

Scripting

Frontier's scripting language UserTalk is a language that lets you calculate, repeat, and abstract. It's a scripting language, by which I mean that what it operates upon is your computer itself.

It can ask your computer questions: what time is it? what are the names of the files in this folder? It can tell your computer to do things: delete this file, start up that application. It can read and write files directly (if they are text files).

And, if an application is "scriptable," it can communicate with that application, asking it questions and giving it commands, thus letting you take advantage of the abilities of your word-processor or your browser or whatever, incorporating those abilities into a UserTalk program. UserTalk is a programming language that has your whole computer as its scripting domain.

So Frontier is a command center from which you can put your computer's power to work for you.

Frontier is where you can turn when it occurs to you that you're doing something on your computer, or wishing to do something on your computer, that involves calculation, repetition, or abstraction. And UserTalk is the language in which you construct your commands.

PreviousNext

   

Site Scripted By Frontier © Copyright 1996-98 UserLand Software. This page was last built on 2/10/98; 1:27:22 AM. It was originally posted on 4/15/97; 8:53:00 PM. Webmaster: brent@scripting.com.

 
This tutorial was adapted for Frontier 5 by Brent Simmons, from the Frontier 4 scripting tutorial written by Matt Neuburg.