PROSPEC Computer Systems This is the eighth README file for Expert86 This file covers the PCW version of the ED.COM editor, which may be used to produce knowledge bases for Expert86. Unfortunately the Amstrad manuals contain very little information on the ED editor so we provide a summary of the ED commands and a beginners tutorial on the program in this file. ED is a simple line editor which is supplied with virtually all CP/M systems. A line editor allows you to edit a single line at a time, in contrast to word processors or text editors you may have met, which provide full screen editing, allowing you to see a screen full of text at a time and to edit any part of the text by moving the cursor to it on the screen. Screen editors are rather simpler to use than line editors. However for the task of producing knowledge bases for Expert86, which tend to be fairly short files in general, ED may be used without too much trouble. We'll begin by showing you how to create a new file with ED. Then we will show how the file may be edited, and finally how to edit an existing file and save the amended version. We will use a file called PRACTICE. If you want to work through this example it might be a good idea to make sure that your disk does not already contain any file called practice. If it does we would suggest that you rename it to something like PRACTICE.OLD by typing: ren practice.old = practice (followed by RETURN). Now, to use ED to create a brand new file called PRACTICE, type: ed practice The computer should respond with: NEW FILE : * The '*' is ED's prompt. Whenever you see it, ED is waiting for you to type a command. In the examples that follow, anything that appears after a '*' must be typed in by yourself. 'I' is the insert command, and allows you to enter text into the file. If you press 'I' the screen should look like this: NEW FILE : * I 1: Now you can type in whatever text you wish to put in PRACTICE. At the end of every line press the RETURN key, and when you have finished press the EXIT key. Unfortunately, if you make a mistake there is nothing you can do at this stage. Neither the DELete keys nor the arrow keys (normally used to move the cursor around) will work. We will cover ways of editing a file later on. For the moment, if you make a mistake don't worry about it. Carry on, and you can correct it later. It will be good practice for you. We would suggest that you use the following piece of text: ONE TWO THREE FOUR FIVE SEEVN ATE NINE Type it in exactly as it appears, errors and all, so that we can go back and make corrections later. When you have finished, press EXIT and you should see the prompt: : * again. As we have said, ED is a line editor which means that it looks at one line at a time. It might plan to place text on that line, edit the line or delete it, but it can only turn its attention to one line at once. It uses something called a "Line Pointer" to keep track of where it is. The line pointer contains the number of the line that ED is currently considering. When you pressed 'I' to begin inserting text, the machine responded with: NEW FILE : * I 1: The '1' indicates that the line pointer is at line 1, the perfect place to begin writing to a new file. The line pointer is important. When you edit a file you must first make the line pointer point to the line you want to change. We will therefore spend the next few paragraphs showing how the put the line pointer where you want it. To move the line pointer to the very beginning of the file use the 'B' command (for beginning): : *B 1: * To see the whole file at this stage press '#T' (T standing for type) and you should see: 1: *#T 1: ONE TWO THREE 2: FOUR FIVE 3: SEEVN ATE 4: NINE 1: * Note that the last line tells you that the line pointer is still at line 1. To move the line pointer to a different line you can use the 'L' (line) command. If you press 'L' the display should show: 1: *L 2: * The line pointer is now at line 2. Pressing 'L' again moves it to line 3: 2: *L 3: * To go backwards, simply use a minus sign in front of L: 3: *-L 2: *-L 1: * You can move several lines at a time by inserting a number before 'L'. Put the line pointer at the start of the file if it is not there already (with the 'B' command, as before) and then type '2L': : *B 1: *2L 3: * This has moved the line pointer 2 lines forward. To go back to line 1 use '-2L' 3: *-2L 1: * This is one alternative to 'B'. There are other alternatives. To get to a specific line you can type in the line number followed by a colon, and ED will set the line pointer to point to that line. For example, if you are at line 1 and want to move to line 3, type: 1: *3: 3: * so now we have another way of getting to the beginning of the file, with the '1:' command. As an alternative to '2L' you can simply use '2' (no colon this time), in which case ED will move the line pointer forward by two lines, just as with '2L', but now it will also show you the contents of the line it has reached. 1: *2 3: SEEVN ATE 3: * '-2', as you might have guessed, does the same job but moves backwards from the line you start at. A final way of moving through the file is by means of the RETURN key. Go to the beginning of the file again and press RETURN several times. Each strike of RETURN causes ED to move the line pointer one line forward, and to display the line it reaches. When the line pointer comes to the end of the file, the RETURN key has no further effect. RETURN performs exactly the same function as the '1' command. Earlier on we used '#T' to list out the file. 'T' is the main listing command, and '#T' causes every line from the line pointer to the end of the file to be displayed. Therefore, if the line pointer is at line 1 the complete file is shown, but if it is at the last line only one line is shown. 'nT' (where n is any number) may be employed to display n lines of text, again starting with the line pointed to by the line pointer. In this example, the first two lines can be displayed with '2T': 1: *2T 1: ONE TWO THREE 2: FOUR FIVE 1: * Editing In addition to the line pointer, ED uses a second pointer called the character pointer. Just as the line pointer points to a line in a file, the character pointer points to a character in a line. To insert text somewhere on a line the line pointer must be made to point to the line and the character pointer must point to the position within the line that the text should go. The character pointer is moved forward or backward with the 'C' command. To illustrate the way 'C' works, move to line 1 and press 'C' (and RETURN). Then press 'T' to display the line. 'T' prints the line pointed to by the line pointer, from the character pointed to by the character pointer to the end of the line. When you pressed 'C' you advanced the character pointer one charcter forwards, so the first character in the line is not displayed by 'T'. 1: *C 1: *T NE TWO THREE 1: * To go back one character press '-C'. Alternatively, 0L (i.e. zero followed by L) will move the character pointer back to the beginning of the line, regardless of where you currently are. Now, let's begin to correct the errors in the file. The first error is in line two, where 'SIX' is missing. Move the line pointer to line 2 with '2:'. The line contains 9 characters, so you can move to the end of it with '9C'. Then press 'I' to enter insert mode and the screen should look something like this: 1: *2: 2: *T 2: FOUR FIVE 2: *9C 2: *T 2: *I 2: FOUR FIVE Now type in a space followed by 'SIX' and EXIT. Move to the beginning of the file with 'B' and list out the file with '#T'. 3: *B 1: *#T 1: ONE TWO THREE 2: FOUR FIVE SIX 3: SEEVN ATE 4: NINE 1: * If all has gone well the correction should be complete. Line three contains a couple of spelling errors. Move to line 3 and advance the character pointer past the first two characters: 1: *3: 3: *2C Now press '2D' which will delete the first two characters after the character pointer (i.e. to the right of the character pointer), go back to the start of the line with '0L' and list it with 'T'. 3: *2D 3: *0L 3: *T 3: SEN ATE 3: * Now we must add 'VE' to make 'SEVEN'. This can be done with: 3: *2C 3: *I type in VE and press EXIT 3: *0L 3: *T 3: SEVEN ATE 3: * To get rid of ATE, skip past SEVEN and the space with '6C', and delete 'ATE' with '3D'. Then press 'I' and type in 'EIGHT'. 3: *6C 3: *3D 3: *I type in EIGHT and EXIT 3: *0L 3: *T 3: SEVEN EIGHT 3: * Finally, we will move 'NINE' from line 4 to the end of line 3. Move the character pointer to the end of line 3 and type '2D', which will get rid of the carriage return and line feed following 'EIGHT'. 3: *11C 3: *T 3: *2D 3: *T NINE 3: *B 1: *#T 1: ONE TWO THREE 2: FOUR FIVE SIX 3: SEVEN EIGHTNINE 1: * As you will see, a space is needed between 'EIGHT' and 'NINE'. It can be inserted by using the following commands. 1: *3: 3: *11C 3: *I 3: SEVEN EIGHT type in a space and EXIT 3: *B 3: *#T 1: ONE TWO THREE 2: FOUR FIVE SIX 3: SEVEN EIGHT NINE 1: * If you want to be clever you can put a number of commands on a single line, one after the other. In the above example we could have said: 1: *3:11CISEVEN EIGHT{ALT-Z}B#T 1: ONE TWO THREE 2: FOUR FIVE SIX 3: SEVEN EIGHT NINE 1: * but we believe that the simpler approach is preferable. {ALT-Z} means that you should hold down the ALT key and press Z. Some advanced commands Sometimes it is useful to be able to search for a particular word or sequence of words in a file that ED is editing. The F command serves this function. For example, to find the first occurance of NINE, go to the beginning of the file and type FNINE followed by ALT and Z simultaneously: 1: *FNINE{ALT-Z} ED will search for the string following F and will move the character pointer and line pointer to it. Press T to look at the rest of the line and you should see: 1: *FNINE{ALT-Z} 3: *T 3: * because ED has moved the character pointer to the end of line 3, so T can find no more text on the line to show you. If you want to see everything on the line BEFORE the character pointer you can use 0T (that is, zero followed by T): 3: *0T 3: SEVEN EIGHT NINE* The S command may be used to search for one string and replace it with another. If we wanted to replace NINE with nine we could say: 1: *SNINE{ALT-Z}nine{ALT-Z} and ED would look for the first occurance of NINE and replace it, in this instance, with a lower case version of itself. The most complex replace command is J, standing for juxtapose. J takes three strings of the form: J{ALT-Z}{ALT-Z}{ALT-Z} and works like this. To begin with it searches for the first occurance of string1. Then it deletes everything it finds following string1 up to, but not including, string3. Finally it inserts string2 in the newly created gap. For example, earlier we faced the problem of correcting SEEVN to SEVEN. The juxtapose command could have done the job: JSE{ALT-Z}N{ALT-Z}VE{ALT-Z} ED searches for SE, deletes everything following it as far as N (i.e. EV) and inserts VE between SE and N. These commands seem complex but, of course, you do not need to learn them. ED works perfectly well without them, as we have already shown. A command like juxtapose can be helpful (if you happen to remember it) but there are always other ways of doing what you have in mind. For example, search-and- replace would do the job equally well, with: SSEEVN{ALT-Z}SEVEN{ALT-Z} Editing an existing file To save the text you have been preparing with ED onto disk you should use the E command which will return you to CP/M. If you want to edit the file again at a later date you can invoke the editor with: ed practice (or ED PRACTICE, it makes no difference) assuming that you have called the file PRACTICE as we suggested. The machine will respond with: : * Note that there is no line number as yet. If you expected to see: 1: * you will be disappointed. No matter how hard you try, you will not be able to inspect your text yet. The reason is that ED has not yet loaded the text into it's workspace. Why not? Because the file may be so large that it will not all fit into memory in one go, and ED has left it to you to load in all or part of the text as appropriate. Since you are unlikely ever to write very long knowledge bases you can safely load the complete contents of PRACTICE in one go with: : *#A Other variations on the A command will load part of the text - see the command summary at the end of this file to find out more. Now you should see: 1: * and you're in business. Edit the text as necessary and leave with E as before. As a final frill, it is possible to take text from one file, edit it, and save the result in a second file. If you want to do this you must invoke ED with: ED source-filename destination-filename where source-filename is the name of the file where the text will be taken from, and destination-filename is the name of the file where it will be saved on exit. For example, to edit the text in PRACTICE and save the result in a new file called ALTERED (leaving PRACTICE unchanged) you can type: ED PRACTICE ALTERED ED Command Summary That completes our tutorial on ED. The best way to learn all the commands is to experiment on files of your own. If you get stuck at any point you can usually get back to CP/M with the Q (quit) command. We have presented the common ED commands in the paragraphs above, but we've left out a few of the options which are likely to confuse you at first and be of little help anyway. However, for the sake of completeness here is a full list of ED's commands: #A fetches the whole file from disk and puts it in the editor's workspace if it will fit. The file used is the one which you named when you invoked the editor nA fetches n lines from the file and puts them in the workspace 0A fetches text from disk until the workspace is half full, leaving you room to add more lines if you wish B moves the line pointer to the beginning of the workspace -B moves the line pointer to the end of the workspace nC, -nC moves the character pointer n characters forwards through the current line. If n is negative the character pointer is moved backwards nD, -nD deletes the next n characters after the character pointer. n may be negative E saves the edited file onto disk and returns you to CP/M F{ALT-Z} looks for the word specified in , beginning at the character pointer and working to the end of the workspace buffer H saves the latest version of the edit to disk and allows you to carry on editing from the beginning of the file i enter insert mode - text is put in the file exactly as you type it I same as i but text is automatically converted to upper case before it is stored I{ALT-Z} inserts immediately after the character pointer J{ALT-Z}{ALT-Z} deletes everything from the end of string1 to the beginning of string3, and substitutes string2 in place of the deletion. nK, -nK deletes the next n lines after the line pointer - DON'T CONFUSE THIS with the nD command nL, -nL moves the line pointer n lines forward through the workspace 0L (zero-L) moves the character pointer to the beginning of the current line nM causes ED to execute (which may be any ED commands except M itself) n times. E.g. 5ML is a rather long-winded way of moving the line pointer forward by five lines. n, -n moves the line pointer n lines forward n: moves the line pointer to line n :n execute up to line n N{ALT-Z} This is similar to the F string search command, but it will repeatedly perform #W0A if the string cannot be found in the current workspace. Therefore it searches the whole file rather than just the part of it you happen to have in ED's workspace. O abandons all editing so far, and fetches a fresh copy of the file from disk for further editing nP, -nP moves the line pointer 30 lines forward and displays 30 lines from there on - in other words, P causes ED to move to the next page of text and to show it to you. Note that this command is documented incorrectly in the PCW manual and in the HELP.COM utility Q quits the edit and returns you to CP/M - i.e. the changes you have made are NOT saved onto disk R{ALT-Z} reads the file called into ED, appending it to whatever is already there nS{ALT-Z} beginning at the current position of the line pointer and character pointer, ED looks for appearances of and replaces them with . It does this n times. It is the search-and-replace command. nT displays n lines beginning with the line indicated by the line pointer. #T displays the whole file, from the current position of the line pointer to the end 0T displays the current line from the start to the position of the character pointer. Therefore, if the character pointer points to the middle of a line, 0T will display the first half of the line and T will display the second half. U, -U translates any further text to upper case as it is typed in V, -V V turns line numbering on; -V turns it off nW writes the first n lines in the workspace to the file #W writes the rest of the buffer to the output file 0W writes to the file until the workspace is half empty nX writes the next n lines from the workspace to the file called , adding them to any text already in the file nZ wait n seconds (no, we don't know why either!) # causes to be repeated as many times as possible. For example, K deletes the next line - #K deletes the rest of the workspace. # may be used with any command that can take a repeat count (n) to mean 'as often as possible'. Thus #T displays the whole file and #Sfred{ALT-Z} finds the last occurance of 'fred'. Commands may be concatenated on one line as we have already shown. If a command that ends with ALT-Z is the last command on a line then the ALT-Z may be omitted. Commands that end the edit (E, H, O and Q) must be on a line of their own. When it left us this disk contained: HELP.COM - advice on getting started README.1 - introduction to Expert86 README.2 - details of our Expert86 competition README.3 - details of other PROSPEC shareware products README.4 - how to copy Expert86 README.5 - more information on Expert86 README.6 - how to use Expert86 README.7 - a blank order form [README.8] - this file E86.COM - the Expert86 expert system generator CAR - a sample expert system for Expert86 - training set CAR.ATT - a sample expert system for Expert86 - definitions LIST.COM - a utility, similar to TYPE.COM PROSPEC Computer Systems Shareware PO BOX 28 Beeston Nottingham NG9 1PH Great Britain