[ Home | Prev | Next ]

Chapter 10: continued


Example: Activity Tracker Suite

This section walks through the process of creating a suite to track your activities. Whenever you develop software -- including simple scripts -- it's helpful to have a plan. Here are the steps we will follow:
  1. Describe the desired functionality.
  2. Define the needed UserTalk scripts.
  3. Define and build the menu to call these scripts.
  4. Write the scripts.
  5. Attach the new scripts to the new menu.
  6. Create any empty documents or objects needed by the scripts.
  7. Test the suite.
  8. Add the suite to the Suites or Custom menu.
  9. Test the launch of the suite from the menu.
  10. Save the revised root.

Describing the Desired Functionality

The suite we want to build will allow us to keep a running chronological list of our accomplishments. Each day will be a summit in a Frontier outline. Under each day will be one or more sub-headings, each containing a brief description of some task we accomplished that day. The outline will look something like Figure 10-6.


Figure 10-6. Sample List of Accomplishments

We want to be able to add items to the list as easily as possible. The program should keep track of today's date and make sure that it adds things to the right day's list. We also want to be able to ask the program how many things we've accomplished since we started keeping the list.

Notice that because Frontier has a built-in outliner, there are a number of things we don't have to build into our application (suite). For example, printing is handled for us. So are deleting items, editing their contents, and examining them in context. Frontier's wealth of integrated features dramatically reduce your development time.

Defining the Needed Scripts

From the description of what we want our suite to do, we can come up with a list of the scripts we'll have to write.

We need a script we can invoke with a menu command that asks us to identify an accomplishment, opens the list, finds out if this is the first one for today, adds a heading for today's date if necessary, and finally insert the accomplishment. We also need a script that will tell us how many items we've added to the list since we created it.

Implied but not explicitly described is a need for another script: one that will simply open the list so we can review it, print it, or work with it.

A suite also has three standard scripts: one to edit this suite's menu, one to edit its table, and one to install its menu when the suite is launched by the user.

Defining and Building the Menu

Since the menu is simple, let's build it right away. First, we need to create a table in the suites table to hold the menu, scripts and data. Let's call this new item "Activities." Jump to the suites table with Cmd-J and typing "suites" in the dialog.

Select "New Sub-Table" from the "Table" menu then type the name "Activities" into the dialog. (Of course, you could also press Command-Return to create a new entry, and select "Table" from the "Kind" popup menu.) Click the Zoom button or double-click this new entry's item marker and you'll find yourself editing an empty table (see Figure 10-7).


Figure 10-7. Empty "Activities" Table

Since the first thing we want to build is this suite's menu, let's enter it into the table. Type "menu" and click Zoom or double-click the item marker; you'll be in a menubar editor (see Figure 10-8).


Figure 10-8. Blank Menubar Editor

Notice the window's title. You are editing the menu entry in the Activities sub-table in the suites table at the root level of Frontier.

A menu has one summit, the name that will appear on the menu bar when the menu is displayed. Call it what you like; we'll use "Tracker." Type this title in at the summit of this menubar outline editor. Press Return and then Tab.

The first item in this menu ought to be the one we expect to use most often, probably adding items to the list. Type "Add an Item" -- but before you press Return, pause for a moment. If we're going to be really busy adding things to this list of accomplishments, we might want a keyboard shortcut for invoking the process. Since it's so easy to add this feature in Frontier, let's do it. Deciding which character to use is a bit tricky. You might be tempted to use "A" since it's the first letter of the menu entry. The problem is, the Edit menu uses this Command-key equivalent to select all of the text. You might well want to be able to do that with the Tracker suite open. We chose to use Command-I ("Item") instead. If you prefer some other key, feel free to substitute it. Don't use Command-M or Command-T, though, because we're going to define those later in this menu.

Look at the Frontier menubar. Notice that it is building your menu as you create it! This immediate feedback enables you to check to make sure the menu looks like you want it to look before you move on to the next task.

Following the same procedure, add the following items to the Tracker menu:

The menu as you view it in the editor should now look like Figure 10-9. Its menubar version looks like Figure 10-10.


Figure 10-9. Tracker Menu Nearly Complete in Menubar Editor


Figure 10-10. Tracker Menu Nearly Complete on Menu Bar

There is one thing wrong with the menu as it now stands. All of its functions are jammed together. There aren't any separators (dotted or gray horizontal lines) to separate the items into logical groups. Let's add two separators, one after "Edit the List" and one after "How Many Activities?". To do that, just position the bar cursor in the menubar editor on the line before the desired separator (in the first case, "Edit the List") and press Return. Now type a single hyphen. Repeat the process for the second separator.

As long as we're polishing things up, let's make another change. Select the text "Add an Item" and type an ellipsis (Option-semicolon) at the end of it. This lets the user know that when this menu item is selected, a dialog box will appear in which the user will be expected to provide some information. Now the menu looks like Figure 10-11.


Figure 10-11. Final Version of Tracker Menu Pull-Down

As you can see, this version is much cleaner and easier to read.

Contents Page | Previous Section | Next Section -- Write the Needed Scripts
HTML formatting by Steven Noreyko January 1996, User Guide revised by UserLand June 1996