• Aucun résultat trouvé

word processor or text editor which can save a text-only file, I—I

Dans le document Lt QU (Page 68-72)

one without imbedded command characters in the text. (To create such a file using TextCraft, for instance, you must choose the Text Only option on the Save Document screen.) Another method, perhaps one of the handiest, of creating command sequence files is to use a console window as a mini text editor. Chapter 4 showed you how to do this.

The file you create should contain one or more lines of CLI commands, one command to a line, with a RETURN character at the end of each line. The format should look like this:

ECHO "The current date and time settings are:"

DATE ECHO " "

n

Command Sequence Files

ECHO "The current device assignments are:"

ASSIGN

SAY All, done.

Notice that you've just used a new command, ECHO.

ECHO prints out the text string enclosed in quotes. It's really only useful when included in command sequence files. By placing ECHO statements in command files, you can let the user know what the command file is doing.

The SAY command, found in the last line above, is simi lar to the ECHO command except that it uses the Amiga Nar rator device and Translator library to actually speak the words typed on the command line. Notice that with the SAY com mand, no quotation marks enclose the text—if you included quotation marks, your Amiga would try to speak them. Also, notice the use of punctuation marks to change the inflection of the speech.

Let's assume that you've created a disk file in the current directory named Report, which contains the lines of text listed above. You could then type EXECUTE Report, and each of the commands in the file would be executed in sequence, producing the following screen output:

The current date and time settings Saturday 15-Nov-86 18:27:01

Command Sequence Files

In the above example, it's assumed that the file Report was in the current directory. If it were in another directory, you could have used the full pathname to identify its location (EXECUTE dfl-.Utilities/Report). But there's another way to make the EXECUTE command execute a command sequence file not located in the current directory. As you may remember from the previous chapter, the system assigns the logical de vice name S: to the the s directory on the boot disk when you turn on the computer. The EXECUTE command first looks for the command file in the current directory, but if it doesn't find it there, it looks in the S: directory. By saving your command files to the S: device, therefore, you can be sure that EXECUTE will always be able to find it, regardless of which directory is current.

Startup-Sequence: The Autoexecuting Command File As has been mentioned several times already, AmigaDOS rec ognizes a special command sequence file located in the S:

directory called startup-sequence. The sequence of commands contained in the startup-sequence file is executed whenever you turn on the machine or reset it by holding down CTRL and both Amiga keys. To see the standard command file which comes on the Workbench disk, enter TYPE S: startup-sequence. The displayed file should look like this:

echo "Workbench disk

The first four commands use the ECHO program to send messages to the screen. The LoadWb program is used to load the Workbench. Finally, the command endcli > nil: is used to terminate the CLI process and suppress its sign-off message by redirecting output to the NIL: device.

The startup-sequence command file is a powerful tool be cause it lets you specify what happens every time you turn on your Amiga. For instance, you can specify whether you want to load the Workbench every time or stay in CLI mode or both. You've already seen that to stay in CLI mode, all you

u

u

Command Sequence Files

have to do is leave out the last two lines of the standard file.

But if you want to load the Workbench and keep a CLI win dow, you can insert the line

NEWCLI con:20/20/200/100/

right before the LoadWb line. This starts up a smaller CLI win dow that will stay on the Workbench screen after the Work bench is loaded. (See Chapter 6 for details on how to edit a file such as startup-sequence. Briefly, though, to add this line, type ED s/startup-sequence, which puts you in the screen editor. Use the cursor keys to move to the LoadWb line, press RETURN, cursor up to the empty line, and enter what you see above. Press ESC, then enter X, and press RETURN. The new startup-sequence file will overwrite the old. Warm start your Amiga by pressing the CTRL key and both Amiga keys at the same time. The Workbench should appear, along with a CLI window.)

There are a number of other things you may want to do automatically at startup time. If you're using a hard disk or ex ternal memory, you may have to run a program to integrate these resources into the system. One of the most useful sequences of commands to include in the startup-sequence file is one that sets up a RAM disk directory containing a collection of your most frequently used commands and ASSIGNS it as the default command directory. The simplest sequence to use is

MAKEDIR RAM:C COPY SYS:c ram:c ALL ASSIGN c: RAM:C

This is faster than copying each individual file since DOS doesn't have to read the COPY program from disk each time.

The disadvantage is that you end up using a lot of RAM to hold command programs you seldom, if ever, use. Taking up over 128K of RAM for command programs is wasteful on a 512K system and prohibitive on a 256K system. The alternative is to copy files selectively. You can do this one of two ways.

First, you can copy all of the files from C: which you want to go to the RAM disk to a new directory called D. Then, replace the SYSx reference in the above example to SYS:d. This speeds up the time it takes to transfer the files, but wastes some disk space by duplicating existing files.

Command Sequence Files

u

The other choice is to copy specific files individually.

Something like this may be what you'll use:

MAKEDIR RAM:c , ,

COPY c/copy RAM:c/copy | |

ASSIGN X: ram: c/copy

ASSIGN D: ram:c (

CD SYS:c I

X: assign D:

X: cd D: , ,

X: delete D: | |

X: dir D:

X: diskcopy D:

X: echo D:

X: ed D:

X: endcli D:

X: info D:

X: join D:

X: list D:

X: Makedir D:

X: newcli D:

X: rename D:

X: run D:

X: type D:

CD SYS:

ASSIGN C: RAM:C ASSIGN D: C:delete

This first copies the COPY program to RAM:, then uses I I

Dans le document Lt QU (Page 68-72)