CLI Prompts And Printing  by James Margitich  Ed: For more on this interesting subject, check out MD6 and MD18, which both have interesting tutorials.  36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36   Author's Biopic: I am an Amiga owner of about three and a half years. My main computing interest is programming but I do lots of other things as well, too many to mention. My favourite games are Lemmings and Populous II (still) but I haven't had a lot of time to play them recently for obvious reasons. I have an A500 with two floppy drives, 1 meg of RAM, a 1084s monitor, and a printer.  Huh? For those who are wondering what CLI prompts and printing have to do with each other, the answer is "Escape Codes". Escape codes are codes that are used for doing fancy things like italics, underlining and all sorts of good stuff. The interesting thing is, you use the same codes for both screen and printer. Escape Codes The first I had ever heard about escape codes was in the first Amiga magazine that I ever bought, Amiga Resource February 1990. It was in the CLI Clips column by Jim Butterfield if you want to refer to it. That column had most of what I'll be talking about in the rest of this article in it but I've tried to explain more simply so that anyone can understand. Anyway, escape codes are commands that are embedded in text strings. A text string is simply a line of text with quotes on either end, e.g.  "This is a text string" but you can type anything between the quotes. When you enter such strings, as part of a CLI prompt or simply to display on screen via the ECHO command for instance, an asterisk (*) signals the start of an escape code. This could be a problem if you wanted an asterisk as part of your string. As an example, say you wanted to print the string  "This string contains an * and more" on the screen. If you simply entered  echo "This string contains an * and more" in the CLI or Shell, it wouldn't work. If you wanted that string to appear on the screen you would have to enter  echo "This string contains an ** and more" which looks wrong but isn't. The first asterisk indicates the start of an escape code, the second asterisk tells the Amiga that you want to put an asterisk into the string. You might be wondering how you would put quotes into a string. If you entered  echo "This string has "quotes" in it" you would be disappointed. The way to do it is to enter  echo "This string has *"quotes*" in it" for the same reason given above. The same applies to the escape character. If you want to put one into a text string, which you do to indicate the start of an escape code (hence the name), then you use *e. CLI Prompts If you want to customise your CLI or Shell prompt, then simply fire up your favourite text editor (or any text editor you can find) on the file s:shell-startup. Please note that if you are using AmigaDOS 1.2 (or earlier?) you need to work on the file CLI-startup (I think, I bought my Amiga after the switch to 1.3 so I'm not sure). Delete any PROMPT commands that might be there and enter the prompt you want to use (with any escape codes you want). As an example, here is the one I use:  prompt "*e[33m *e[42m *e[3m %S *e[0m *n? " which gives me the current directory in grey-blue text on a white background in italics with a question mark prompt in normal colours on the next line. Before I explain what each part of that command means, I'd better explain about the colours. Any colour changes set either the foreground or background colour to a certain colour NUMBER e.g. colour 3 rather that grey-blue. The only reason the foreground colour was changed to grey-blue is because on my workbench, colour 3 is a grey-blue. On a standard 1.3 system it would be orange. The *e[33m bit sets the foreground colour to colour 3 and *e[42m sets the background colour to colour 1, which is black on 1.3 and white on 2 and above. The *e[3m turns on italics and %S prints the current directory. The *e[0m resets everything back to the default, *n signals a new line and the question mark is my prompt character and the space is there because I like having a space after the prompt character.  Printing You can also use escape codes when you're printing. If you're about to print something from the shell and you would like to put a title on it first, simply use this command before you start priniting:  echo >PRT: "Title and stuff" remembering that you can use escape codes for your title. The >PRT: (it doesn't have to be in capitals, >prt: will work just as well) sends the output to the printer instead of the screen. It's also worth remembering that you use the same escape codes whether you're printing to the screen or the printer. This is because the escape codes are interpreted by AmigaDOS and are nothing to do with the printer. The printer.device, referred to as PRT: in the shell, uses the printer driver currently selected in preferences to determine what codes should actually be sent to the printer. So you can write script files or programs which send escape codes to the printer and as long as they use PRT: and not PAR: or SER: (for a serial printer) then someone else with a completely different printer can use them as well. Reference All of the escape codes that are recognised by the printer.device (there are lots of them that are only for printers and are useless from the shell) are listed in Appendix C of "Mapping The Amiga" by Rhett Anderson and Randy Thompson and published by Compute! Books. This list gives the name assigned to the code by the standard include files, the code itself and the function. Please note that sending one of these codes merely gives your printer the command to perform the function the code is defined as. If your printer doesn't have a particular feature, such as reverse line feeds, then the corresponding code will have no effect. Most printers have the majority of these capabilities but if you are unsure check the manual.  36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36 -+- 36