< Previous | Contents (GEM) | Contents (DOS+) | Next >
Generally speaking, you will be creating and editing files within your application programs. For example, you would normally create text files using your word processor, program files using your compiler program, record files using your database program, and so on. And then you would change those files using the same application program that you used to create it.
However, sometimes you may want to create or edit text files in DOS Plus, perhaps because you want to run a batch program as described in the next chapter. There are two ways of creating a text file in DOS Plus: you can either `copy' it from the keyboard or use the ED text editor to type it into a file.
The COPY command is used to copy files between discs, as described in Chapter 4, but it can also be used to copy files to and from other devices such as a printer, screen or keyboard. Therefore, you can 'copy' a file from the keyboard into a file on disc, thus creating a file.
To do this you specify the source file (where the file originates) as CON: (the console), in a statement such as:
A>COPY CON: batch.bat RETURN
Whatever you type in after RETURN will then be recorded in the file batch.bat on drive A. You can type in anything you want, and it might typically be a few lines of DOS Plus commands.
Atthe end of the last line, enter CTRL and Z (press Z whilst holding down the CTRL key) instead of RETURN and you will be returned to the command line prompt, A>. You have created a text file batch.bat that contains the characters you typed in and can be processed in the same way as any text file.
So, COPY CON: is a quick and easy way of creating files. But you cannot correct typing errors during the copy, so you need to be very careful, and therefore this method is practical only for text files of a few lines. The ED text editor is probably easier to use for creating larger text files, and you can also use ED for correcting errors in your COPY CON text file.
The text editor, ED, can be used to create text files or to edit existing text files. It is designed as a programmers editor rather than for word-processing as such. ED is a comprehensive editing program, and only the basic writing and editing commands are documented here.
If you wanted to create a new file called (for example) batch.tex. You would call the editor with the command:
A>ED batch.tex RETURN
A new file, batch.tex would then be opened and you would see the ED prompt asterisk on the left hand side of the screen.
You are in the ED command mode after typing the above command, so any characters you type will be interpreted as commands by DOS Plus. So the first thing to do is put ED into insert mode by typing:
:*i RETURN
Now type in the text you want (ignoring any typing errors for the moment), and when you have finished press CTRL and Z to change back into command mode, indicated by the :*.
Your text is now stored in a buffer. To write your text to your file batch.bat, enter the command:
:*e RETURN
which ends the edit session. You now have a file batch.tex on the disc in drive A.
If you now want to edit your file, call ED again:
A>ED batch.tex RETURN
ED now displays
:*
to show that its pointer (an imaginary cursor) is at the beginning of the buffer.
First you want to bring the text into the buffer by entering
:*#a RETURN
Then to display the contents of the buffer on the screen. You do this by entering the 'page' command that moves the pointer to the end of a 23-line 'page' of text:
:*OP RETURN
Now you can move the pointer to the place in the file that you want to edit with the commands:
ln to move the pointer up or down by n lines, and
cn to move the pointer right or left by n characters.
For example:
:*l4 RETURN
:*C-8 RETURN
will move the pointer down four lines and left eight places. And:
:*l-2 RETURN
:*c3 RETURN
will move the pointer up two lines and right three places.
At any point
:*Op RETURN
will display the text to the right and below the current pointer position.
Once you have the pointer where you want it, you can insert characters (by using the command i followed by the characters, followed by CTRL and Z), to delete characters using the command d with a number to indicate how many characters to delete. For example:
:*d-4 RETURN
will erase the four characters on the left of the cursor position. If you get confused
:*b RETURN
will move your pointer to the start of the buffer.
Carry on in this way until you are happy with the text and then use the command e to end the editing sequence and write your text from the buffer into the file. ED will, as a precaution, retain the original, unedited file and change its filetype to bak to signify that it is a backup file – so in our example the original file batch.tex would be renamed as batch.bak.
In some cases you may want to use a fuller version of ED, specifying a destination filename as well as a source filename, for example:
A>ED B:source.tex A:newname.tex RETURN
In this case file source.tex on drive B will be preserved intact and the edited version of source.tex will be written to the file newname.tex on the drive A.
This description of ED has assumed that you are creating and editing small files (less than 23 lines in length), and therefore has given only a few of the ED commands. In fact you can do quite complex things with ED such as searching for strings of characters, substituting strings, deleting lines, repeating a group of commands, and so on. These facilities are described in the DOS Plus Users' Guide and the DOS Plus Programmers' Reference Guide.