[ Home | Prev | Next ]

Chapter 2: continued


The Menubar Window and Scripts

Frontier's menubar has four permanent menus: Apple, File, Edit, and Window. The rest of the menus are open for you to create, delete, reorganize, or modify. All editing of the menubar is done through the menubar window. There are several ways to open that window: When you do open this window, it will look something like Figure 2-19 (again, allowing for the possibility that it may appear different on your screen for any of a number of reasons).

Just as spreadsheets allow you to work with rows and columns of numbers, and word processors are good at editing and revising letters and reports, the menu editor in Frontier lets you edit the menubar as if it were a document.

The menu editor works just like an outline. Double-click on the item marker to the left of each line to expand and collapse sub-heads. Switch in and out of text mode (so you can edit individual menu entries) by pressing the Enter key. The arrow keys move the cursor.

Any changes you make in the outline are automatically and immediately reflected in the menubar.


Figure 2-19. The Menubar Editing Window

Any menu item can have a script linked to it. To create, edit, or examine the script activated by a menu item, select the item and then click on the "Script" button in the upper right corner of the menubar editor's window. For example, let's find "Hello World." If the Custom Menu isn't fully expanded and visible, scroll to it in the menubar editor and then double-click on the item marker immediately to the left of the headline "Custom." Locate the submenu called "Fun Stuff." If it isn't expanded to show the items it contains, double-click on the item marker immediately to its left. Figure 2-20 shows what this part of the menubar outline should look like.


Figure 2-20. Partial Custom Menu Outline

Pull down the Custom menu and have a look at the "Fun Stuff" menu. There should be a one-to-one correspondence between what you see in the menubar and what you see in this window. Put the cursor on "Hello World" in the menubar editing window and click on the Script button in the upper right corner. This zooms out the script window linked to the "Hello World" entry in the menu, as shown in Figure 2-21.


Figure 2-21. Script Associated with Menu Entry

You can run the script by clicking on the "Run" button, or by selecting the item from the menu. Clicking on the "Run" button executes the script to completion. Clicking on the "Debug" button gives you a wide choice of debugging options (see Figure 2-22).


Figure 2-22. Script-Editing Window in Debug Mode

Click on the "Go" button to run the program. It will come as no surprise, given our earlier experiment in the Quick Script window, that the Main Window now has a message in it saying "Hello World."

Bring the menubar window to the front, move the cursor to "Count to 10" and click on the Script button. This is a simple loop that counts to 10 in the Main Window (see Listing 2-1).


Listing 2-1

First, the script initializes a temporary variable, named counter, to 0. Then it loops, adding one to counter until it's greater than 10. Every time through the loop it uses the msg verb to display the value of counter in the Main Window.

Click on "Run" and watch it work. Notice that the numbers one through 10 appear in the Main Window. (On fast machines, Frontier will count so quickly that it will be difficult to see each number.) Now choose "Count to 10" from the Custom Menu's "Fun Stuff" sub-menu; naturally, you see the same result.

Note that the script could be simplified; see Listing 2-2.


Listing 2-2

Contents Page | Previous Section | Next Section -- A Sample Frontier Scripting Session


HTML formatting by Steven Noreyko January 1996, User Guide revised by UserLand June 1996