Edit and BAT files

If you aren't used to editing text files or creating batch files, you are now about to participate in a mini-course. But first a warning! Don't begin to alter your startup files until you know what you are doing! The responsibility rests with you.

EDIT.COM starts a text editor called QBASIC.EXE, which we will use to create and alter a batch file. It can also create programs in the BASIC language. At the DOS prompt, enter EDIT to see if the program starts. If not, perhaps C:\DOS isn't in your PATH in AUTOEXEC.BAT, or perhaps one of the files is missing. If it starts, press Esc, Alt+F and X to close it.

I suggest that you have a directory called BAT where you can store your batch files. If you do not already have one, you can create one by typing


Move to this directory by entering


What is a batch file? Well, if you type the same DOS commands time and again, it can pay to write these commands in what is called a batch file, a text file containing DOS commands that has BAT as its extension.

The following is a quick way to create a text file. Try it, just to see the principle behind it. Let's make a file called EASY.BAT. (note: copy con means copy from the console, the console being a term covering both the screen and the keyboard).

C:\BAT>copy con easy.bat

The cursor blinks and you are "in" a text file. Type




cd \dos


cd \bat

Press F6 to end the file, then Enter. DOS displays '1 file (s) copied'

Copy con easy.bat means "copy from the console (keyboard)," i.e. copy what I type into a file called EASY.BAT. The file EASY.BAT has been created. Now, just by entering EASY you can "run" this batch file. Try it. It shows the contents of two directories. By pressing Ctrl+S, you can stop and start the process if you want to follow it. (Ctrl+S means to hold the Ctrl key down while you press the S key.)

Now make a batch file called ED.BAT, which will automatically start EDIT and load EASY.BAT in the editor.

C:\BAT>copy con ed.bat

edit C:\bat\easy.bat

press F6 and Enter.

When you now enter ED and Enter, EDIT will start and load the file C:\BAT\EASY.BAT.

The EDIT editor consists of a rectangular area where you can type and edit as in a simplified word processor. The name of the file you are working on is shown at the top of the screen. At the top and bottom, there are horizontal bars. The top bar contains the menus used for editing.

All of the words FILE EDIT HELP are "headlines" for independent menus that drop down from the bars like a roller blind when you click on the word with your mouse. If you are using the keyboard, then the menu bar is activated by holding the Alt key down while you press the underlined letter of the menu command you want, e.g. open the File command by pressing Alt+F.

This is how you move a line - which can be relevant if you want to edit a startup file using this editor. Place the cursor at the beginning of the line. Hold down the Shift key and press the "down arrow" key. The line is marked (highlighted). Press Shift+Del(ete). The marked line vanishes from the screen and is placed in a temporary store. Move the cursor to the point where you would like the line to appear and press Shift+Ins(ert) and the line is inserted.

Close EDIT with Alt+F, X. If the file has changed (which in this case it has), you will be asked if you want to save it. The Tab key moves you between the possibilities or you can just type the initial letter. In this case, answer NO to keep your original file. Now create the following two batch files. EC.BAT starts the editing with CONFIG.SYS loaded, and EA.BAT starts the editor with AUTOEXEC.BAT loaded. The two directories DOS and BAT should be in your PATH.

C:\BAT>copy con ec.bat

edit c:\config.sys

Press F6 and Enter.

C:\BAT>copy con ea.bat

edit c:\autoexec.bat

Press F6 and Enter.

But remember those early words of caution: don't begin editing your startup files until you know what you are doing!

You may notice with EDIT that there is no "word wrap" - where the screen shows a new line even though you haven't put in a carriage return. Text editors work in different ways but most of them work like this: text between two carriage returns (a carriage return is when you press Enter) is shown as one line that continues past the monitor's right-hand boundary, and can contain up to a maximum of 256 characters. You will have to get used to this. But many key combinations, such as Ctrl+arrow, work exactly the same as in other programs. It is an advantage that a text editor doesn't have word wrap: the computer reads BAT and INI files line by line, so it could cause havoc if a line gets broken unexpectedly into two lines ' as if it were two sets of instructions.


This is only relevant for DOS, not Windows. Understanding ASCII (American Standard Code for Information Interchange) was one of my first breakthroughs many years ago. It is pronounced "aski" and is a standard for the relationship between a symbol and a number.

When you press a key on your keyboard and the screen shows a character, it is nice to think that the character is just sitting in the key, just waiting to be activated. But it is not so simple.

I am going to jump over the scancode, which is what is actually sent when you press a key. This code is sent to a "converter" that decides which ASCII value is linked to the scancode, and then this ASCII value is again "converted" to a character on your screen.

In computing, only two states are possible: on or off, 0 or 1, and nothing else; and this fills 1 bit. A computer can only move 1s and 0s around, nothing else! Eight of these 1s or 0s grouped together are called a byte, and the letters and symbols you use are each defined by a series of 1s and 0s assembled into an eight-partition electronic box. Each partition can contain either a one or a zero (binary system).

With eight partitions, each of which contains one of two (0 or 1) available values, there are 256 possible patterns (2 multiplied by itself eight times) for creating a number value. As zero is also a valid number, you will often hear of the set of values referred to as 0-255.

Fortunately, computer manufacturers are pretty much in agreement over which symbol or letter should be allocated to which of the 256 values in the ASCII system. Let's use the capital letter "A" as an example. At the DOS prompt, or in a DOS word processor, try holding the left-hand Alt key down while you key in two or three digits on the numeric keyboard, for instance 65.

Then, to make everything a bit more fun (though easier for programmers) when they created Windows, Microsoft introduced another standard called ANSI, which uses other character values.

Luckily, the normal letters and numbers are unaltered, but a text file stored as ASCII and one stored as ANSI are two different things. Text files saved by DOS programs are in ASCII format, while text files saved by Windows are in ANSI (by default, anyway). Write and other Windows word processors are able to save in either format and convert between the two.

These are some of the foundations of data communication. We humans have not really got any further in mimicking the brain and soul's development, but it is progressing. The only reason for the computer's wide use is its speed. Forget about "intelligent" computers, even though experts are trying to convince us it is possible with talk of neural networks and the like.

Copyright © 2022-2023 by Michael Maardt. You are on knowware.dkContact