Classic Computer Magazine Archive COMPUTE! ISSUE 95 / APRIL 1988 / PAGE 60

The Elementary Amiga

Part 5

Jim Butterfield, Contributing Editor

In this final installment, Jim takes a close look at the CLI's RUN command. After describing several other commands, he explains the often-misunderstood AmigaDOS pattern-matching features.

The Commodore Amiga comes with excellent documentation. Both the Introduction and the Amiga Basic manuals take you gently through the first steps, and the AmigaDOS User's Manual will bring you into the CLI environment. But the facts don't always give you the flavor of the machine. This time, we'll discuss some of my favorite CLI (Command Line Interface) commands and talk more about multitasking.

Multitasking is easy, convenient, and sometimes even (dare I say it?) fun. It often takes place without your realizing it. For example, when you put a disk into the drive, you may notice that the drive light comes on for a few seconds. That's a separate task, or program, that the computer has generated. This task will do its job without interfering with anything else that may be happening. It vanishes when it has finished.

By the way, that's part of the reason you should wait a few moments when you first crank up your Amiga. Following the LOADWB (load Workbench) command, a task looks through the Workbench disk, checking that everything is in order. You can start clicking or typing right away—which would start a new task in motion—but it's not a good idea. Chances are, whatever you wanted to do would involve use of the disk drive. The two tasks (yours and the continuing one) might fight for access to the disk, moving the head back and forth, wasting everybody's time.

You will usually create multiple tasks in one of three ways. The most obvious method is to click on a Workbench icon to start something going. The Workbench doesn't go away, so if you want to set something else in motion, all you need is another double-click (perhaps with a little rearranging of windows to permit visibility), and the next task is under way.

A related method is to click on the CLI icon repeatedly. Each time the user does so, a new CLI is created, complete with its own window. Each CLI is capable of performing a separate task. By clicking into a CLI window and giving a command, a new job begins.

Once any CLI process is open, we can create new tasks in two ways. The command NEWCLI, as the name suggests, asks for a new CLI window to be opened. You may then click into the new window and start whatever work you want.

Using RUN

But the handiest way of starting a new and separate task is to use the command RUN. The keyword RUN is prefixed to whatever else you want to do.

Thus, instead of ED S/STARTUP-SEQUENCE, you might command RUN ED S/STARTUP-SEQUENCE. What's the difference? ED by itself means that your CLI will go and do the ED job; you can give no more CLI commands until the edit is finished (at least not in that CLI window). But RUN ED ... means that the Amiga will start a new CLI and give it the ED job. In the latter case, you could click out of the editor window to go to your original CLI, for example, to look at a disk directory while the edit is still under way.

To take this example a step further: You could compare, side by side, two text files by using two ED programs at the same time. Let's follow the command sequence to do this:

RUN ED DF0:S/STARTUP-SEQUENCE

Now, shrink the edit window, click back into your original CLI window, and then type

RUN ED DF1:S/STARTUP-SEQUENCE

Shrink the second edit window, too, and drag it so that you can see both windows. You might arrange them side-by-side or one window above the other. It's easy to compare text files this way.

Don't forget to click into each edit window and abandon the edits with ESC Q. Or, if you do something you want to keep on disk, the sequence is ESC X.

RUN Windows

In contrast to the NEWCLI command, RUN does not create a new CLI window. As you experiment with various commands, you'll see that some use the current window, some set up a new one, and some commands (such as AMIGABASIC) set up whole screens.

Suppose we want to perform a directory listing as a separate task: While the directory is appearing, we'd like to be doing something else. DIR performs a directory list, as does LIST. But if we type RUN DIR, we may have problems, since the results pour into the same window in which we're trying to work. It's messy, to say the least.

Redirection is the answer to this problem. By using a phrase such as >XXX immediately behind the command word, the results will go to XXX. XXX could be a file, for example, or the printer; or it could be a window that we set up specially for the job. Let's use the window option (CON:) to illustrate a point about placement of the redirection command.

I stated that you should put the redirection signal directly behind the command. But now there are two commands (RUN and DIR). Which one should it follow? Try both of the following commands:

RUN >CON:20/20/500/100/files DIR
 DF0:
RUN DIR >CON:20/20/500/100/files
 DF0:

Aha! We see that the output of RUN is a simple notice, [CLI 2], but the output of DIR is, of course, the directory itself. So, the second form of the command is the one we want, redirecting the output of DIR. Now we can better understand the reason why the redirection has to be carefully placed.

Indeed, we can have more than one redirection. Let's suppose you have a hatred of that CLI 2 notice. You could throw it away by redirecting it to nowhere, or device NIL:. Here's how:

RUN >NIL: DIR >CON:20/20/500/100/files DF0:

You can see that the CLI notice was thrown away, while the directory came out as usual.

All this is not completely satisfactory, however. The window we set up vanishes the moment the DIR command finishes, giving us no time to read the last few files. We could get around this by setting up a script file containing the DIR command followed by a WAIT and then commanding RUN EXECUTE >CON:, but that seems like a lot of work. We could use NEWCLI, do the job in the new, permanent window and then end the task with ENDCLI.

But there's an easier way. Try this:

RUN DIR >RAM:FILES DF0:

This will redirect the directory listing to a file in the ramdisk called FILES. At your convenience, you may TYPE RAM:FILES and later delete the file.

ECHO

At first, the ECHO command seems to belong only in the STARTUP-SEQUENCE file. It turns out to be quite handy. If you make your own script file which you will execute later, ECHO gives you useful status reports.

I find myself using ECHO frequently with redirection. If I want to set up a disk file called TEST which contains the words testing 123, I can quickly type ECHO >DF0:TEST "TESTING 123" There are many other ways to do the same thing, of course—ED will do the job and so will the command COPY * TO DF0:—but ECHO is quick when you have a simple job to do.

Before listing a file to the printer, I like to add extra information such as the date. ECHO >PRT: "Today is Apr 14, 1988" will do the trick.

You may even use ECHO to send special formatting commands to the printer. The technical details are beyond the scope of this article, but it's interesting to know that ECHO >PRT: "*e[4w" will switch my printer into "condensed print" mode ("*e[0w" puts it back) and may well do the same on yours.

COPY And JOIN

COPY makes a copy of a file (you probably guessed this), and JOIN can do the same thing. JOIN FILE1 AS FILE2 makes a copy in exactly the same way as COPY FILE1 FILE2.

If you want to move a file from one directory to another on the same disk, don't use COPY. RENAME will do the job more neatly.

Keep in mind that COPY and JOIN don't need to use disk files: Any appropriate device will do. You might use the console ("*") or the printer (PRT:). Thus, to list a file, you don't need to use the TYPE command. COPY FILE * will deliver to the CLI window; COPY FILE PRT: will deliver to the printer. You can even create an instant word processor with the command COPY * PRT: if you wish. In this case, keep in mind that CTRL- \ will end the file transfer.

If you want to print several files, JOIN FILE1 FILE2 FILE3 AS PRT: will do the job. To separate the file listings, you might wish to create a dummy file with some blank lines or a vertical-tab (paper eject) and cause that to be printed between each of the other files.

I think the keyword here is versatility. At first sight, a command seems to do one thing, but as you learn of the system's flexibility, it becomes capable of much more.

ASSIGN, INFO, And STATUS

I use ASSIGN, INFO, and STATUS frequently. They are designed to give you an understanding of what's happening within your computer.

We've mentioned ASSIGN before. It can be used creatively, to identify special disks in the session, or routinely, to reassign a resource such as fonts to another disk (or to the ramdisk). You also can use it just for information; the ASSIGN command alone gives you an idea of how your system is set up.

INFO tells you about your disk resources. It tells you how full each disk is, plus other useful information.

STATUS tells you about the tasks, mostly the CLI activities, in your machine. It's more for "inner space" enthusiasts, but it will give you an idea of the bookkeeping taking place within the Amiga. Try STATUS FULL for more details (you don't need to understand everything you see there.)

DATE And SetClock

DATE allows you to see the current date and time. DATE followed by other material allows you to set these values.

If you have an Amiga 2000 or a 500 with the memory expansion fitted, SETCLOCK OPT LOAD will read in the date and time from the built-in clock.

If you don't have a built-in clock, it's a good idea to keep the date current. When you write to disk, the files are time- and date-stamped. Accurate dates are a great help in identifying program versions. There are even some backup programs that update files if their recorded date is too old.

Your system disk records the last time and date at which a file was written. If you don't have a built-in clock, it's a good idea to update this each time you use the Amiga. For example, try the sequence:

ECHO >K "X"
DELETE K

This writes a tiny file (named K) and then immediately deletes it. Even so, the disk has recorded the current date and time. If you're a frequent user, remember that a command such as DATE TOMORROW will move things ahead one day, or DATE FRIDAY will move the date ahead to the following Friday. It's easier than typing in the whole date.

Pattern Matching

Some commands allow you to partially specify a file and then find it (or a group of files) by using pattern matching. The simplest characters are:

# any number of the following character or pattern
? any character
| inclusive "or" for characters or patterns

For example, A#B means an A followed by any number of B's, which would match A, AB, ABB, and so on. The two characters #? used together are very powerful, meaning "any number of any characters." Thus, A#? would match any filename beginning with A, and #?.info would match any file ending with .info—a very powerful feature indeed.

The "or" symbol can save you a lot of typing. You might type:

DELETE DOG|CAT|MUTT #?

This would delete any file named DOG, any file named CAT, and all files whose names begin with the characters MUTT.

Not all commands permit pattern matching, but it's useful when it's there.