• Keine Ergebnisse gefunden

Usi ng the Edi tor

Im Dokument Level One (Seite 30-33)

The files you will edit are called ·block files· because they are made up of a sequence of ·blocks· (old-time FORTH programmers may prefer the term

·screens·). A block is the fundamental unit of disc storage used by MacFORTH.

It is simply a fixed length record containing 1024 characters for programs.

The ·FORTH Blocks· file on the MacFORTH system disc contains the source code for some MacFORTH utilities, as well as empty space for your use.

You should organize your program source code logically into files by categories. For example, you can see that we put the MacFORTH utilities in the ·FORTH Blocks· file, the demo programs in the ·Demo Blocks· file, and the Going FORTH tutorial source code in the ·Going FORTW file. By logically organizing your source code into files you will find program development great1y simplified.

Practice Editing Block

In order to illustrate the use of the editor, we have provided a practice block for you to work with while completing this chapter. Begin by displaying the practice block with the editor. Execute

5 EDIT

You should now see on your screen an edit window which looks like figure 3.1 below:

~o Blk# 5 of 23 ; File=Forth Blotks ( Sample Editing Practice Block)

CR ," Loading Editor Practice Block, ,"

I lfr

,PLUS (n1\n2 -- I add n1 to n2 and display the result CR OUER, ," p I us .. OliP , + ," equa Is" ,

CR ," Editor Practice Block Loaded,"

Figure 3.1

Program Edi t i ng Page 3 - 5 August 27, 1984

Editor Window

The MacFORTH edi tor uses its own wi ndow. The wi ndow is large enough to display one block of source code in a format 16 Hnes by 64 characters each for a total of 1024 characters (as you can see in Figure 3.1). The following list points out the features of the editor:

- Title Bar

Displays the current block number being edited, the total number of blocks in the file and the file name. Each time you edit a different block this information is updated to show you exactly what you are editing.

- Close Box

lets you close the editor window by clicking in its close box. The edi tor wi ndow wi 11 reappear the next time you enter the edi tor.

- Drag Regi on

Allows you to drag the edit window to a new position on the screen (remember to keep the entire window Yisible when editing).

- Scroll Bar

The vertical bar on the right hand side of the window is the scroll bar.

It al10ws you to scroll up and down within the current program file, selecting different blocks for editing.

-UpArrow

Selects the preYious block (numbered one less than the current block) as the block to edit. Stops on the first block in the file.

- Down Arrow

Selects the next block (numbered one more than the current block) as the block to edit. stops on the last block in the file.

- Scroll Box

Drag the scroll box to select another block to edit. Moye it up to edit lower numbered blOCKS and down to edit higher numbered ones.

- Shaded Area

Click inside the shaded area aboye or below the scroll box to moye 3 blocks at a time in either direction (up or down).

Program Editing Page 3 - 6 August 27, 1984

Experimenting with the Editor

Let's try a few of the editor features:

Close Box

First, click inside the close box. The editor window disappears and the MacFORTH window becomes the active window. To make the editor window reappear, re-enter the editor by executing (from the MacFORTH window):

5 EDIT

within the shaded area above or below the scroll box. Click in the shaded area below the scroll box once. You are now editing block 8 (you were previously mouse button to display the block being edited.

Moving the scroll box to the top position in the shaded area will position you pOSition the scroll box approximately half way between the top and bottom of the scroll bar. Try to find block 12 now using the above technique.

Program Edi t i ng Page 3 - 7 August 27, 1984

Edit Menu

The Edit menu provides you with the following options while editing. Each item in the menu provides a powerful function at your fingertips (don't try these features just yet; simply read through the I1st to famillarize yourself with them):

Undo

(H2)

Undoes the previous

cut,

cOPy, or paste operation (including any changes since the last operation). It actually restores the contents of the block to the version since the last

cut,

copy or paste operation.

Cut

(HX)

Cuts the current selection range (discussed later in this chapter) from the text and places it on the clipboard.

(Cut,

copy and paste use the clipboard just like other Macintosh applications).

Copy

(He)

Copies the current selection range (discussed later in this chapter) to the c 1 i pboard.

Paste

(HU)

Inserts the contents of the clipboard to the block at the current cursor position and/or replaces the current selection range.

Stamp

(HS)

Stamps the current block with the current date, as read from the internal clock, and initials stored in the user Yariable INITIALS. Use the word @INIT to change the yalue in INITIALS. DATE displays the current initials and date stamp. If the first three characters in INITIALS are non-printable ASCII characters or blanks, the stamp function is disabled.

Clean

Blank fills the contents of the block currently being edited. Use this command with caution as you

cannot

undo it.

Revert

Resets the contents of the current block back to the version sayed on the di sc. Use thi s command wi th cauti on as you

cannot

undo it.

Im Dokument Level One (Seite 30-33)