• Aucun résultat trouvé

Console and Others

Dans le document GUIDE AMIGA (Page 61-64)

The console device is used to accept input from the keyboard and the mouse, and to print the characters on the screen. Output goes to a window on the screen, known as the console window. The con-sole device accepts input from the keyboard a line at a time. At any point before you press the RETURN key, you may edit the line using CTRL-H or the BACK SPACE key to delete characters, and CTRL-X to delete the entire line (see Chapter 2 for more infor-mation about the editing capabilities of the console device). When the console receives a line of text, it translates the keystrokes into ASCII and extended ANSI codes. As noted in Chapter 2, the con-sole device itself responds like an ANSI terminal to many escape codes that control things like cursor positioning, screen scrolling, line insertion and deletion, and the like.

Workbench 1.3 comes with an enhanced console device called NEWCON:, which introduces new features like line editing and command history. Since this device is not automatically recognized by AmigaDOS, but must be added with the MOUNT command, we'll cover it more fully in the treatment of MOUNTable devices, below.

Each CLI comes with its own console window (it's the window in which the >n prompt appears). When you use the NEWCLI command to start a new CLI process, you may specify the starting position, size, and title of its console window (see Chapter 2 for more information on starting a new CLI process). If you don't spec-ify these characteristics, a default console window is used.

It's possible, however, to create your own console windows that aren't related to any existing CLI process. To do so, you refer to the device as

CON:hpos/vpos/width/height/windowtitle

where hpos is the horizontal position of the top left corner of the window (expressed as the number of pixels in from the left edge of the screen), vpos is the vertical position of the top left corner of the window (expressed as the number of pixels down from the top edge of the screen), and width and height give the size of the win-dow in pixels. The maximum size for a console winwin-dow is the screen size, normally 640 X 200 pixels. The minimum is 81 X 25 pixels. The last entry, windowtitle, is optional and allows you to en-ter a title that will appear in the title bar. If you don't enter a title, the title bar is left blank. Note that the final slash is required, even when you don't specify a title.

Each console window comes with a sizing gadget to change its size, but the window doesn't redisplay the current data after you

Devices

change the window size. This means if you make the window smaller, the text in the area the window previously occupied is wiped out. If you later make the window larger again, the new area of the window will be blank, rather than holding its old con-tents. Besides the sizing gadget, each console window has the depth arrangement gadgets in the upper right corner, which let you send the window to the back of the screen or bring it forward on top of another window. Console windows also have a drag gadget (which coincides with the title bar) that lets you change the posi-tion of the window on the screen.

Like the RAM: device, you create a new console window by referring to its device name. For instance, to LIST the directory to a new console window, you could type

LIST TO CON:0/0/640/100/

Try this, and you'll see that although a new console window is created and the listing prints within it, it disappears as soon as the command is completed. Though you can pause the display before it disappears by hitting any key (use the BACK SPACE key to re-start), the short-lived nature of such a window limits its usefulness as an output device.

Console as Input

The console window can also be used as an input device. In this role, it can act as a mini text editor, which can be used to create small text files or printed documents. For example, you can create a text file on the RAM: disk by typing

COPY "CON:40/40/200/100/File Creator" TO RAM:text The new console window appears and is the active window.

Start typing text, using the BACK SPACE key to delete errors.

When you've finished a line, press the RETURN key and that line is sent to the file. When you finish, enter a CTRL- '\ character to signal AmigaDOS that you're at the end of the file. Enter this char-acter by holding down the CTRL key and pressing the backslash ( '\) key, located next to the left of the BACK SPACE key. When you end the file, the window disappears and the disk file is closed.

To see the contents of that file, enter TYPE RAM:text

The console device gives you a handy way to create a small file (like the command sequence files discussed later). You can also send input from a console device to any other device (even another

conso~e window). For example, type

COPY CON:40/40/200/100/Typewriter TO PRT:

Devices and each line that you type in the window is sent to the system printer (as soon as you press RETURN). Again, use CTRL- " to end the session.

In addition to the new console windows you create, you can also use the existing console windows belonging to your CLls. Do this by referring to the active console device, named

*

(asterisk).

This use of the asterisk should not be confused with the universal wildcard character used by MS-DOS or the asterisk used as an es-cape character before quotation marks in a filename. As an output device,

*

is more durable than CON: since the window doesn't vanish after each command. Unfortunately, it's not much more use-ful, since most commands output to the current console window anyway. It, too, can be used as an input device, and as such, it's even handier to type

COpy * TO textfile

than specifying a long CON: device name. This is a quick and easy way to create a short text file.

RAW

There's one more window device available to AmigaDOS, but it's really only suitable for application programs and not for general use by the CLI command programs. This device is called RAW:, and it's an apt name. A normal console window heavily filters what comes through it. You'll notice, for example, that the cursor keys have no effect when you're typing in a console window. The RAW:

device, on the other hand, doesn't filter anything. Thus, it would be nice to use if you wanted to create a file that containes charac-ters other than the standard letcharac-ters, numbers, and punctuation marks-such as cursor movement codes. But, alas, RAW: passes through the CTRL- " without interpreting it as an end-of-file char-acter. So while a CON: disappears before you're through with it, there's no way to close a RAW: window from CLI and therefore no way to close the file to which it's writing. If you really want to play with RAW:, remember that once you create the window, the only way to get rid of it is to warm-start the computer by pressing the CTRL-Amiga-Amiga key combination. A fairly safe experiment for the incurably curious is to type

COpy RAW:0/0/100/50/Input TO RAW:0/50/640/100/

Output

Click in the Input window to activate it and start typing.

Everything you type shows up in the Output window, including cursor movement keys. You can now warm-start the computer,

se-Devices

cure in the knowledge that you've tried everything at least once and that RAW: is as useless for ordinary purposes as we say it is.

It's NIL

Speaking of useless, the last device to investigate does absolutely nothing. True to the British origins of AmigaDOS, it's called NIL:.

When used as an input device, NIL: just sends the end-of-file char-acter. When used as an output device, NIL: accepts the output, and does nothing with it. Still, it's not as useless as it may seem at first.

Programmers sometimes have a use for such devices in testing I/O routines. And even for the casual user, there are occasions where it's useful to get rid of output without showing it to anybody. For example, if you examine the command file called startup-sequence in the s directory, which is normally used to load and run the Workbench, you'll find that the last line of the file reads endcli >

nil:. (You can look at this file by warm-starting the Amiga, then putting the Workbench disk in the drive [the Workbench disk, not the CLI disk you've probably created], opening the System drawer, double-clicking on the CLI icon, and typing TYPE s/startup-se-quence.) The ENDCLI command usually prints the message eLi task n ending (where n is the task number), just before the window disappears. Apparently, the developers didn't want that message to print when the Workbench loaded and so used output redirection (which is discussed at the end of this chapter) to send the offend-ing character stroffend-ing to limbo. Another practical example of usoffend-ing the NIL: device is shown in Chapter 5, which deals with command files, where the output from DATE? is sent to NIL: as a way of al-lowing you to enter the date without seeing the command template as a prompt.

Dans le document GUIDE AMIGA (Page 61-64)