• Keine Ergebnisse gefunden

Error Handling

Im Dokument Level One (Seite 55-59)

When an error occurs in a window other than the MacFORTH window1 the MacFORTH window is actiyated. The error message (if any) is displayed in the MacFORTH window1 not the window the error occurred in.

This enables you to do any debugging from the MacFORTH window1 allowing you to see when and how the error occurred. For e)(amplel actiyate TEST. WINDOW and e)(ecute:

QUERlY

and you will see the error message

QUERlY ?

appear in the MacFORTH window because MacFORTH doesn't understand the word QWERTY.

Forgetting a Window

When you forget a window1 it is remoyed from the Macintosh window list and taken off of the display (if yisible). Forget your new window now by execut lng:

FORGET TESl,UIHDOU

Any references to TEST.WINDOW, as with any other forgotten FORTH word, will not be understood by MacFORTH as it has been remoyed from the dictionary.

Getting Results

PageS -6 August 27, 1984

Window Attributes

You can see that the MacFORTH window has both a size box and a close box;

the editor window has only a close box, and the new window has neither.

These are all attributes about a window that can be included or left off, dependi ng on what you want the wi ndow to do.

Let's continue by creating a new window to work with. Edit the following example into block 2 of your ·Work File Blocks· file:

( He. Uindo. Exaaple ) HEU.UIHDOU EX.UIHDOU

• Exaaple Uindo.- EX.UIHDOU U.TITLE CLOSE.BOX SI2E.BOX

+

EX.UIHDOU U.ATTRIBUTES EX.UIHDOU ADD.UIHDOU

Now load it by executing

2 LOAD

EX.WINDOW has two new features that the preyious window you created didn·t haye: a close box and a size box. The word W.ATTRI8UTES allows you to define the features of a window when it is created. These features were gi yen to the wi ndow when you executed:

CLOSE. BOX SI2E.BOX

+

EX.UIHDOU U.ATTRIBUTES

Refer to the Window chapter for a complete listing of all possible window attributes.

The default title for a window is "Untitled" (as you saw in the first window you created). W.TITLE allows you to assign your own title to a window.

W.TITLE expects a string address on the stack (the string address was left on the stack by the word - ) under the window pointer. By executing

- Exaaple Uindo.- EX.UIHDOU U.TITLE

in the aboye example, you assigned the title "Example Window" to the window EX.WINDOW (we refer to windows by their FORTH name for clarity.)

Getting Results Page 5 - 7 August 27, 1984

Changing the Window Title

You can also change the window title after it has been displayed using the word SET.WTITLE. For example, execute the following to change the name of the new window to "Example Workspace":

• Exa.ple

Uork~pace·

EX.UIHOOU SET.UTITlE

Activate the editor window now (by either clicking in it or choosing the

"Enter Edit" item from the "Edit" menu). Its title is:

BIIc# 2 of 11; File - WORK FILE BLOCKS

Now edit block 1 by clicking the up arrow of the editor control bar. The title of the menu changes to:

BIIc# 1 of 11; File = WORK FILE BLOCKS

The MacFORTH editor uses the SET.WTITLE command to change the title of the editor window each time a different block is displayed.

Closing a Window

When you close a window by clicking in its close box, it is hidden from view.

The window closest to the "front" of the display (the "top" window is then activated. Select EX.WINDOW by executing

EX.UIHOOU SElECT.UIHOOU

Now click in its close box. When EX.WINDOW disappeared, the "top" window became active. Be sure the MacFORTH window is active now by clicking in it.

Hiding and Showing a Window

From the above example, you saw how you can hide a window by clicking in its close box. To make a window re-appear, use the SHOW.WINDOW command.

SHOW.WINDOW re-displays the window specified by the window pOinter given. Execute the following to make EX.WINDOW re-appear:

EX.UIHOOU SHOU.UIHOOU

EX.WINDOW is now there, but it is behind the active window, in this case, the MacFORTH window. To see EX.WINDOW, close the editor window (enter the editor and click in its close box), then close the MacFORTH window by clicking in its close box. There it is!! Remember, SHOW.WINDOW makes the speCified window visible, but not active. A "visible" window is on the desktop, but may be currently under another window.

Getting Results Page 5 - 8 August 27, 1984

You can also hide a window with the HIDE.WINDOW command. Like SHOW.WINDOW, HIDE.WINDOW expects a window pointer on the stack.

Return to the MacFORTH window by selecting the "MacFORTH Window" item from the "Options" menu. Execute the following to make the MacFORTH window disappear:

SYS.UIHDOU HIDE.UIHDOU

Return to the MacFORTH window by selecting the "MacFORTH Window" item from the "Options" menu.

Window Bounds

You can also set the initial position and size of a window using the W.BOUNDS command. Edit the following example into block 3:

( He. Uindo. TEST.UIHDOU2 Exa.ple ) HEU.UIHDOU TEST.UIHDOU2

-

Te~t

Uindo. 2- TEST.UIHDOU2 U.TITLE

188 158

388

i88

TEST.UIHDOU2 U.BOUHDS TEST.UIHDOU2 ADD.UIHDOU

Now load it by executing

3 LOAD

You created a new window named TEST.WINDOW2, gave it the title "Test Window 2", set its starting position to 100,150 relative to the top left corner of the screen (which is at 0,0) and made it a window 200 dots (300-100=200) by 250 dots (400-150=250).

The values 100 150 300 400 defined the window size by giving its "tlbr" <1op, left, bottom, right) values. This 1s easy to remember, because windows have four sides: top, left, bottom, and right. So in the example, the top of the window is100 dots from the top of the screen, the left side of the window is 150 dots from the left side of the screen, the bottom of the window is 300 dots from the top of the screen, the right side of the window is 400 dots from the left side of the screen.

The default window bounds are

188 188 288

388 U. BOUHDS

Getting Results Page 5 - 9 August 27, 1984

Im Dokument Level One (Seite 55-59)