< Previous | Contents | Next >
15 : ED – The Text Editor | |||
ED is a text editor which can be used to create and edit plain text files. It does have a number of basic editing functions but in no way can it be considered a fully fledged wordprocessor. ED can be found on DISC 1.
When you enter ED it must have a file name specified after it. This file name refers to an existing file, or is the name of a new file which you are about to create. The syntax for the command then is:
ED <afn>
It is worth making a copy of ED to an empty formatted disc at this stage, and labelling it as your ED working disc. You can use this to edit and save new text files as you go along – and also experiment as you work through this chapter. To make the copy, first format a new disc and place this in drive B and DISC 1 from the Master 512 disc set drive A. ED can be transferred using PIP thus:
PIP B:=A:ED.CMD
As PIP is itself often used in conjunction with ED, it is worth transferring a working copy of this onto the ED working disc:
PIP B:=A:PIP.CMD
The best way to learn how to use ED is to experiment typing and editing text with it. First ensure that you are typing in capital letter mode, ie ensure that the CAPS LOCK light is illuminated. As mentioned above ED expects, and indeed must be followed by, a filename. When ED is loaded into the transient program area it searches the disc in the logged on drive for the filename specified in the command line. If it finds it then it assumes that you require to edit this, otherwise it assumes that you wish to create a new text file of that name, and therefore does so. In addition, ED creates a dummy file, using the same filename specified but with the file extension $$$ – this is used by ED as a temporary workfile. When you have finished with ED, this file will automatically be erased. Thus if you entered:
ED DEMO.TXT
at the keyboard, ED would open two files on the disc called:
DEMO.TXT
and:
DEMO.$$$
With the newly prepared disc in drive A enter:
ED DEMO.TXT
After a few moments the screen should clear to show:
NEW FILE
: *_
The first line denotes that a new file has been created on the disc. The second line forms part of the ED prompt, which at this stage is waiting to receive a command. There are several ED commands and these will be discussed in the pages that follow.
The first thing to do is to insert some text in the file, to do this use the command 'I', for Insert. The display should now look like this:
NEW FILE
: *I_
Press RETURN, and all being well you will be prompted with a line number thus:
NEW FILE
: *I
1:_
The line number is for reference only, it is not included in the text file, and it enables you to keep track of just where you are and to mark the beginning of a new line of text. For all intents and purposes just ignore it for the time being, and enter several lines of text, terminating each line with a RETURN. You might like to try entering the following text:
NEW FILE
: *I
1: USING ED ON THE MASTER 512
2: CO-PROCESSOR RUNNING UNDER
3: DOS PLUS.
4:
5: DABS PRESS
6: ^Z
: *_
Line 4 appears to be blank – in fact it just contains a RETURN character – a useful way of placing line gaps in between lines of text.
If, at any stage, you make a mistake or typing error, then CTRL-H will erase the character immediately to the left of the cursor. Note that DELETE does not work. ED contains a number of editing facilities and these are discussed later on. Finally, once the text has been entered, return to the ED command mode by pressing CTRL-Z, as depicted in line six.
The text that has been entered is not, as of yet, stored on disc, it remains in memory. There are three commands that will facilitate this, each operating in a slightly different manner. The commands are:
E | Save text on disc and leave ED returning to DOS Plus. | |
H | Save text on disc, but remain in ED editing current file. This allows the file just saved to be altered and/or re-worked. | |
W | Write a number of lines of the current text to the temporary $$$ file. W may be preceded by a number indicating the number of lines to be saved in this manner. Thus 12W will write the first twelve lines to the file. The lines remaining will be 'moved' up and renumbered. #W will write all lines to the $$$ file. |
Clearly each of these commands serves a different purpose. The function of E is self evident. The H command is used when you have finished writing a text file, but you want to go back and edit it. It is also often used for backing up purposes, just in case of power failure or inadvertently hitting BREAK. The W command is used to empty memory, but allowing you to keep on adding to the new file. This is useful in long text files where the memory in the transient program area might not be enough for your needs!
At this point it is worth mentioning that there is another method of leaving ED command mode – by pressing the Q key. Q is for quit and this does not save your text to disc; it eliminates the temporary $$$ file, and wipes out your text from memory, before returning to DOS Plus. Because of the somewhat drastic nature, when you enter Q in ED at command level it will prompt you with:
Q - (Y/N) ?_
Once again this is a safety net for you. If you entered Q by mistake then press the N key, and everything will stay as it was. If you entered the Q(uit) command on purpose then pressing Y will carry out its function.
But back to our demonstration text. Type E to save the current text to disc and then exit ED, your screen should look like this:
A> ED DEMO.TXT
NEW FILE
: *I
1: USING ED ON THE MASTER 512
2: CO-PROCESSOR RUNNING UNDER
3: DOS PLUS.
4:
5: DABS PRESS
6: ^Z
: *EA>_
If you now type:
DIR
you should see that the new file DEMO.TXT has been added to the disc and that the temporary file $$$ has been erased. We can now have a look at the text file by typing it onto the screen. To do this enter:
TYPE DEMO.TXT
the file will then be accessed and printed to the screen:
USING ED ON THE MASTER 512
CO-PROCESSOR RUNNING UNDER
DOS PLUS.DABS PRESS
This shows how simply an information file could be pieced together and used to provide instructions for some future development, perhaps in a batch file.
Suppose we now wished to add some more lines of text to this file, a line containing completion date of the manuscript for example. To do this we must first load the old text file into memory, move the editing cursor to the end of the file and type in the new line or lines, prior to re-saving the amended text. To re-open the file to be added to type:
ED DEMO.TXT
Remember that ED will look to see if the file exists on disc, which in this case it does, it will not overwrite it, but open it up for further use. As the file does exist the NEW FILE message will not appear and the screen will show:
A>ED DEMO.TXT
: *
ED will not load in the existing file unless we tell it to do so. To load the file back into ED for re-editing, we have to use a rather odd looking command:
#A#T-BI
In fact this is not a single command but a series of commands which have the following operations:
#A | A means Append. It tells ED to load the existing file into the memory buffer. #A means bring the entire file into memory. | |
#T | T is for Type. The # stands for 'all', so we can read #T as saying type all the file lines onto the screen (you can halt this at any time with CTRL-S). | |
-B | B is used to move the ED cursor to the beginning of the file currently in memory. By preceding the B with a minus sign, we can move the ED cursor to the end of the file. | |
I | I stands for Insert and informs ED that we wish to insert text into the current file. |
Looking at the command overall then, #A#T-BI reads (deep breath) 'Load current file into memory, type all lines to the screen, move ED cursor to the end of the file and make ready to insert some more text' (breathe out!). Once you enter this command string the screen will show:
A> ED DEMO.TXT
: *#A#T-BI
1: USING ED ON THE MASTER 512
2: CO-PROCESSOR RUNNING UNDER
3: DOS PLUS.
4:
5: DABS PRESS
6: _
The ED cursor is now positioned at line six, so any text we enter will be positioned from herein. Let's add a couple of lines, a RETURN at line six and the extra line of text on line seven, so that the screen shows:
A> ED DEMO.TXT
: *#A#T-BI
1: USING ED ON THE MASTER 512
2: CO-PROCESSOR RUNNING UNDER
3: DOS PLUS.
4:
5: DABS PRESS
6:
7: FINISHED DECEMBER 1988
8: ^Z
:*E
A>_
Again type CTRL-Z to return to ED command mode and enter E to end the current ED session. The amended file will be saved to disc and the DOS Plus will reappear.
When we used the append command above we prefixed it with a hash:
#A
The hash is a wildcard that, when used in this context, means 'all'. Normally ED expects a number in the range 1-65535 to be present before the A. By placing a number before A then, we can specify just how many lines we are loading into memory. Suppose we wished to load just the first four lines of the file DEMO.TXT into memory and carry on from there. We would use:
4A#T-BI
Re-open the DEMO.TXT file in ED and try it, this is what happens:
A> ED DEMO.TXT
: *4A#T-BI
1: USING ED ON THE MASTER 512
2: CO-PROCESSOR RUNNING UNDER
3: DOS PLUS.
4:
5: _
The first four lines of the text file are displayed, with the cursor now positioned at line five. Try entering a few more lines before ending the edit as follows:
A> ED DEMO.TXT
: *4A#T-BI
1: USING ED ON THE MASTER 512
2: CO-PROCESSOR RUNNING UNDER
3: DOS PLUS.
4:
5: ALSO COVERS HOW TO
6: USE PIP AND OTHER
7: DOS PLUS COMMANDS
8: ^Z
: *EA>
The new file contents will now be saved back into the DEMO.TXT file – but what about the 'other' lines that were not appended? Enter:
TYPE DEMO.TXT
to show the file on the screen:
A>TYPE DEMO.TXT
USING ED ON THE MASTER 512
CO-PROCESSOR RUNNING UNDER
DOS PLUS.ALSO COVERS HOW TO
USE PIP AND OTHER
DOS PLUS COMMANDSDABS PRESS
FINISHED DECEMBER 1988A>
Surprise, surprise, the lines just entered have not overwritten the previous lines as one might have expected. This is because the new text has been Inserted into the current file, and ED has moved the undisplayed text up beyond it. Using this method text can be inserted anywhere within an existing file as required. Occasionally, it may occur that ED can't load all of a file into memory – though this would be a very long file indeed. If this is the case then you'll get an error message similar to this:
BREAK ">" AT A
In cases such as this you'll need to load smaller sections of the file into memory with commands such as:
100A
to work on.
A special command is:
0A
this causes ED to load lines into memory until the memory area is about half full, or until all lines have been loaded, if this happens first.
Line numbering occurs when we enter ED's Insert mode, however this feature can be turned on and off if so required. The commands are,
V turn line numbering on -V turn line numbering off
Both of these commands should be used in ED command mode and typed directly after the asterisk prompt thus:
*-VI
means, 'turn line numbering off and enter Insert mode.
So far everything you will have typed in will have been in upper case. Now create a new file and enter text using lower case characters, ie with the CAPS LOCK light extinguished. Create the new ED file thus:
ED CASE.TXT
When the prompt appears enter Insert mode and type the following text, exiting the file with E.
A> ED CASE.TXT
NEW FILE
: *I
1: this text is entered entirely
2: in lower case characters
3: ^Z
: *EA>
What happens if we now type this file to the screen?
A>TYPE CASE.TXT
THIS TEXT IS ENTERED ENTIRELY
IN LOWER CASE CHARACTERSA>
What a lie! The text that we did initially enter in lower case is now in uppercase. This is because ED automatically converts all lower case characters into upper case after they are entered, unless we instruct otherwise. The commands to turn this translation on and off are:
U Turn lower to upper translation on -U Turn lower to upper translation off
To ensure that lower case remains lower case -U should be entered in command mode, before Insert mode is selected, ie:
*-UI
Now any text entered will keep the case assigned to it, be it upper or lower case.
< Previous | Contents | Next >