Meet
ED The AmigaDOS Editor
Christopher J. Flynn
Christopher J. Flynn
AmigaDOS-the command-driven operating system which underlies the graphics-oriented Workbench-contains two text editors. Although they aren't full-fledged word processors, these editors are ideal for entering program source code, creating batch files, and even writing short documents. This article shows how to use ED, the more powerful of the two editors. For more information on AmigaDOS and batch files, see "Introduction To AmigaDOS," a two-part series in the January and February 1986 issues of COMPUTE!, and "AmigaDOS Batch Files," April 1986.
The Amiga comes with more software than most people realize. Besides Amiga BASIC, Electronic Arts' Kaleidoscope, Mindscape's Amiga Tutor, the RAM disk, the speech synthesizer, the printer drivers, the icon editor, the calculator, the clock, and numerous demo programs, there are also three complete text editors. Most people know about the Notepad because it's available from the Workbench. But the other two text editors-ED and EDIT-don't show up as icons and must be run from an AmigaDOS CLI (Command Line Interface) window.
The most powerful of these text editors is ED. Although it doesn't handle multiple fonts and styles like the Notepad, it has many more editing functions and is the ideal tool for writing AmigaDOS batch files or program source code. EDIT, on the other hand, is a little more specialized. It is a sequential file editor. In practice, EDIT is best used to make changes to an existing disk file. You'll probably prefer to use ED for composing new text.
We'll be exploring ED version 1.10. Future releases of ED may change things around a little and introduce new features, so keep this in mind.
Starting ED
Where is ED hiding? Even if you peek through every nook and cranny of the Workbench, you will not find an icon for ED. It turns out that ED is actually an AmigaDOS command. This means that you have to start ED from a CLI window.
If you've never used a CLI window before, your first step will be to activate the CLI. Open the Work bench and check the contents of the System drawer. If CLIs are activated, you'll see a cube-shaped icon labeled CLI in this drawer. If the icon is not present, point to the Preferences icon and double-click the mouse's left button. Look for the CLI On/Off selector on the Preferences screen and click on the On box, then exit Preferences by specifying Save (not Use). Now when you reopen the System drawer, it should contain a CLI icon. If not, go back to Preferences and make sure CLI is turned on. (If you find yourself using the CLI often, you may want to drag the CLI icon from the System drawer into the main Workbench window to avoid the extra step of opening the System drawer.) To open a CLI window, double-click on the CLI icon. Now you'll have a window in which you can type AmigaDOS commands.
ED can be started in two ways:
ED filename [SIZE n]
RUN ED filename [SIZE n]
The first method starts ED from the CLI which you've just activated. It ties up the CLI until you're finished with ED. In other words, you have to leave ED before issuing other AmigaDOS commands. When you specify RUN ED, AmigaDOS automatically starts another CLI task for you and starts ED in this new CLI. Thus, you can temporarily suspend ED by moving the mouse to another window. You can go back to the original CLI and issue other AmigaDOS commands. If you are adventuresome, you can even have multiple ED sessions in progress at the same time. (What you're really doing is multitasking more than one AmigaDOS simultaneously.)
In either case, the ED command requires a filename. You can either supply the name of an existing disk file you wish to edit, or create a new file by specifying a new filename. Remember that Amiga filenames can be up to 30 characters long. So, choose filenames that take advantage of this feature. It helps you recognize your files later on.
There is a SIZE option for the ED command. (Don't type in the brackets, by the way. Brackets just signify options.) A text document must be able to fit entirely in memory. ED just cannot handle a document partly on disk and partly in memory. The SIZE option gives you a way of telling ED how much memory you want to set aside for working on the document. If you don't type in SIZE, ED will set aside 40K for you. The maximum SIZE is determined by the amount of memory you have.
Here are a few examples of commands for starting up ED:
ED GROCERY-LIST
ED WAR-PEACE-BOOK-REPORT SIZE
90000
When SIZE is used, type out the number. Note that 90,000 bytes is typed as 90000 and not as 90,000 or 90K.
Leaving ED
When ED has been successfully started, its display occupies the entire screen. So, how can you return to the CLI? There is no close gadget on ED's window. There is nothing to point at and click. Instead, ED requires either a Quit or an Exit command. Press the ESC (escape) key. An asterisk appears on the last line of the display. Type either Q for Quit or X for Exit and then RETURN. That's all there is to it.
There is a difference between Quit and Exit. Q leaves the editor without saving the document to disk. Anything you have typed will be lost. ED recognizes that this can be quite an inconvenience, so if you do type Q, ED displays the following warning message:
Edits will be lost - type Y to confirm:
Pressing Y at this point gets you out of ED, and no text is saved. If you type anything else, ED lets you continue working on your document.
ESC-X, the Exit option, does save the document on disk, using the filename you specified when you started ED. No messages are given. When ED finishes, you're back in the CLI and can then proceed with other AmigaDOS commands. When you're finished with the CLI, type ENDCLI. If you've got only one CLI window running, this returns you to the Workbench.
ED Commands
There are two types of editor commands in ED. The more direct ones are called immediate commands because you can enter them while typing text. Examples are line insertions and deletions. Immediate commands are always CTRL key combinations. The other category-extended commands-can be typed only when in the command mode. ESC-Q and ESC-X are examples. Pressing ESC opens the lowest display line on your screen for these extended commands.
When ED starts, it positions the cursor at the upper-left corner of the screen. If you are working on a new document, the screen is blank. Otherwise, the screen shows the first page of the document.
If you're creating a new document, just start typing. Notice what happens when the text approaches the right side of the screen. If a word is too long to fit on the remainder of the line, ED pulls the word down to the next line. You can keep typing without being concerned about hitting RETURN at the end of a line as you would on a typewriter.
There are several ways of correcting typos. The BACK SPACE key deletes the character to the left of the cursor. DEL deletes the character under the cursor. Table 1 lists other ways of deleting text.
ED is a full-screen editor, so you can move the cursor wherever you want with the arrow keys. To insert text, position the cursor at the desired location and begin typing. Notice that ED does not have a strikeover mode. Unwanted text has to be deleted-you can't just type over it.
|
The Insertion Gotcha
Try typing a few fairly long lines. Now, move the cursor to the beginning of the text. Start typing again. The existing text on the current line is moved to the right off the edge of the screen. During insertions, ED neither brings the excess text down to the next line nor enforces margins.
The disappearing text is not lost, however. ED has made one long line. The long line can be split at any point by placing the cursor where you want and pressing RETURN. If you're working with ordinary text, not source code or batch files, this may leave gaps of several spaces between sentences. To clean up the appearance, the extra spaces will have to be removed. Some other lines may need adjusting as well.
Using The
Extended Commands
Extended commands (Table 2) can be typed only when ED is in the extended command mode, entered by pressing the ESC key. The cursor appears on the last line of the display. At this point, you can type one or more extended commands. It's quite handy to be able to give ED a series of commands separated by semicolons (;). When you press RETURN, ED acts on the command or commands you've requested.
Extended commands can move the cursor, mark blocks of text for certain operations, and perform searches and exchanges. Some of the operations are tricky and require care. Cursor commands apply only to the cursor position in the text and not to the command line. This is fine except that you can't see the cursor in the text. You have to remember where the cursor is before you use some of the extended commands.
Sections of text can be marked by block start (BS) and block end (BE) commands. Blocks can be deleted, copied elsewhere in the document, or saved to disk. Marking a block involves moving the cursor to the first line in the block and executing the BS extended command. The end of the block is marked similarly with BE. Unfortunately, there is no visible indication of the defined text. Be very careful of cursor movements. The only help ED offers is the show (SH) command. It displays the first and last line of the block and some other information.
|
Text search and exchange operations work without a hitch. You can search forward (F) or backward (BF) through the document. You can exchange (E or EQ) one text string for another. Lowercase text can be treated as matching uppercase text (UC), or it can be treated as not matching (LC).
The repeat (RP) command is often used for exchanges. RP causes the command following it to be exe cuted repeatedly until something (an error, for example) stops it. Thus, RP E carries out multiple exchange operations. Here is an example:
T; RP E /Compute/COMPUTE/
Here, the typing of COMPUTE! is being corrected. T moves the cursor to the top of the document so that the entire document will be examined. RP precedes the exchange command. Note that the two text strings are delimited by slashes. This is ED's convention when text strings are used. A "Search failed" error occurs when Compute can no longer be found in the text. This halts the repeat command, and the entire document will have been corrected.
The save command (SA) saves the document to disk without exiting ED. You should do this periodically to prevent disasters in the event of a power failure.
Overall, ED is an excellent general-purpose text editor. You can use it when programming, since it works with any language that accepts ASCII text files as input (including Amiga BASIC). ED can also prepare data files or help you write short letters and notes. It's not a fancy word processor, but it can handle smaller, less complex tasks quite well.