Fast IBM Batch File EditorTony Roberts, Production Director
Now it's quick and easy to edit and fine-tune batch files with this DOS utility. It works on any IBM PC or PCjr with an 80-column monitor.
The power of the batch file quickly becomes evident to anyone who works regularly in PC-DOS. The hardy AUTOEXEC.BAT handles a variety of chores each time the system is booted, and any number of other .BAT files stand by, ready to help with such tasks as initializing applications, sending out printer codes, and presenting program menus.
The problem with batch files is that to be effective and helpful, they need to be adjusted as your system grows and your applications change. Performing the necessary batch-file maintenance, however, is often so cumbersome that it's discouraging. Loading a full-blown word processor to edit a five-to ten-line batch file can be a lot more time and trouble than it's worth.
"EdBat" solves this problem by focusing all its energy on your batch files. EdBat is without frills, but it's fast and easy to use.
What EdBat Does
EdBat is a full-screen editor with very limited features. Because it is designed for speed, it limits itself to files of fewer than 512 bytes—adequate for most batch files. (If your file is longer, you're probably better off with a more sophisticated editor.)
When called, the program clears the screen and displays the file you want to edit. Using the cursor keys, you can move to the appropriate place, make the necessary changes, and press Alt-S to save the edited file. It is not impossible to open a file, edit it, close it, and be back at the DOS prompt in as little as 15 seconds.
The price you pay for this fast operation is that EdBat has very few features. You're essentially limited to the regular character keys and the cursor keys. The Insert key does not work, the Delete key does not work, nor do the function keys perform any function. The Backspace key moves the cursor back a character, but it does not perform a delete.
If you were writing a novel, these restrictions would be serious, but in batch file editing, none of them is particularly restrictive. With batch files, you're usually just performing one or two simple operations such as adding, deleting, or correcting a line. EdBat can handle all these tasks efficiently.
Using The Program
EdBat is a machine language program that is activated from the DOS prompt. The program listed below, "EdBat Loader," is a BASIC program that creates the file EDBAT.COM from the information in BASIC DATA statements. Type in EdBat Loader using the "IBM Automatic Proofreader," save a copy to disk, and then run it once to create EDBAT.COM.
To run EdBat, enter this line from the DOS prompt:
(The EDBAT.COM file must be on the disk in the current drive when you enter this command.) Filename is the name of the file you wish to edit. Full drive and subdirectory specifications are allowed when indicating a filename. If the file is too long or if EdBat is unable to open the file, the program will print a message and exit. If the file you have specified does not exist, EdBat assumes you are creating a new file.
In a matter of seconds, the file you are to edit is displayed on the screen below a line containing the program title and the name of the current file. If you have started a new file, the screen's work area will be blank.
Use the cursor keys to move around the file, editing as needed. Notice that a triangle signals the end of each line. If you decide to cut a line short, move to the appropriate spot and press Enter. A triangle is inserted and the cursor moves to the beginning of the next line. The screen may continue to show characters beyond the end-of-line marker, but they will be ignored when the file is saved.
To delete an entire line, simply move to the first position on that line and press Enter. An end-of-line marker appears at that spot, indicating that the line will be ignored.
Inserting a line is slightly more difficult since there is no insert function. Move the cursor to the end-of-line marker on the line that will precede your new line. Press Ctrl-Y and a down-arrow character () will replace the end-of-line marker. Add the new line right after the down arrow and press Enter as usual. When the file is saved, the lines will be adjusted.
Saving The Changes
When you're finished editing, press Alt-S to save the file. The program's save routine reads the screen and saves what it sees to your file. It begins with the first line of the text area and continues until it finds a space in the first position of any line. EdBat ignores any characters in a line which follow the first end-of-line marker.
The only other option the program offers is Alt-Q, the Quit option, which returns you to DOS without changing the original file. In nearly every case, your entire file will fit easily on the screen. If part of your file scrolls off the screen, use Alt-Q to quit and find another method of editing the file. EdBat cannot save what it cannot see.
Unlike many word processors, EdBat does not make a backup of your original file. In most cases, though, a backup of a very short file is superfluous. For years, EDLIN, the line editor included with PC-DOS, had been my batch file editor. Eventually, though, I lost patience with it over the time it spent writing backup files and went to work on EdBat.
EdBat Command Summary
|Ctrl-Y||Multistatement delimiter (prints as a down arrow)|
|Enter||End-of-line (prints as left-pointing triangle)|
|Space||Space in first position of line signals text end|
For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.
HL 10 CLS EI 20 OPEN "EDBAT.COM" AS 1 LEN=1 FC 30 FIELD 1,1 AS A$ GP 40 PRINT:PRINT "Writing EDBAT.COM to disk. Please wait." GC 50 FOR I=1 TO 8: READ B$:GOSUB 130:NEXT I CM 60 FOR I=1 TO 75:B$="5F":GOSUB 130:NEXT I GM 70 B$="24":GOSUB 130 OF 80 FOR I=1 TO 74:B$="0":GOSUB 130:NEXT I HG 90 FOR I=1 TO 648:READ B$:GOSUB 130:NEXT I OG 100 CLOSE MA 110 PRINT:PRINT "EDBAT.COM has been created." LO 120 END MF 130 REM write byte to disk QO 140 LSET A$=CHR$(VAL("&H"+B$)) LK 150 PUT #1 MH 160 RETURN DN 170 DATA E9,E0,0,45,64,42,61,74,2,0 CE 180 DATA 2,50,6C,65,61,73,65,20,73,70,65,63,69,66,79,20 EK 190 DATA 66,69,6C,65,6E,61,6D,65,2E,D,A,24,45,72,72,6F EN 200 DATA 72,20,6F,70,65,6E,69,6E,67,20,66,69,6C,65,2E,D BL 210 DATA A,24,46,69,6C,65,20,74,6F,6F,20,6C,6F,6E,67,2E GP 220 DATA D,A,24,FC,BF,54,1,BE,80,0,AC,A2,99,1,FE,E JJ 230 DATA 99,1,3C,0,75,9,BA,A1,1,E8,7,2,E8,25,2,AC FH 240 DATA 3C,D,74,3,AA,EB,F8,E8,BA,1,73,E,3D,2,0,74 GA 250 DATA 30,BA,BC,1,E8,EC,1,E8,A,2,BA,26,4,8B,1E,9A QI 260 DATA 1,8B,E,9F,1,B4,3F,CD,21,3B,6,9F,1,75,C,E8 AD 270 DATA A0,1,BA,D2,1,E8,CB,1,E8,E9,1,A3,96,1,E8,91 HA 280 DATA 1,E8,CB,1,BA,3,1,E8,B9,1,C6,6,9E,1,0,C6 KF 290 DATA 6,9D,1,14,E8,60,1,BE,55,1,33,C9,8A,E,99,1 HP 300 DATA AC,8A,D0,80,FA,61,72,3,80,E2,DF,E8,9C,1,E2,F0 HL 310 DATA C6,6,9E,1,2,C6,6,9D,1,0,E8,3A,1,83,3E,96 OJ 320 DATA 1,0,74,1F,FC,BE,26,4,8B,E,96,1,AC,8A,D0,80 JN 330 DATA FA,D,75,7,B2,11,E8,71,1,B2,D,E8,6C,1,E2,EC HM 340 DATA E8,14,1,B4,0,CD,16,3C,0,74,13,3C,D,74,A,3C NO 350 DATA 8,B4,4B,74,1C,3C,19,72,EA,E8,1F,1,EB,E5,80,FC PE 360 DATA 48,75,E,80,3E,9E,1,2,74,D9,FE,E,9E,1,E8,E6 OG 370 DATA 0,80,FC,4B,75,E,80,3E,9D,1,0,74,C6,FE,E,9D DG 380 DATA 1,E8,D3,0,80,FC,4D,75,E,80,3E,9D,1,4F,74,B3 OJ 390 DATA FE,6,9D,1,E8,C0,0,80,FC,50,75,E,80,3E,9E,1 NJ 400 DATA 18,74,A0,FE,6,9E,1,E8,AD,0,80,FC,10,75,6,E8 QK 410 DATA FD,0,E8,F,1,80,FC,1F,75,89,C7,6,96,1,0,0 JD 420 DATA BF,26,4,C6,6,9E,1,2,C6,6,9D,1,0,E8,87,0 ML 430 DATA C6,6,95,1,0,B4,8,CD,10,3C,20,74,4E,3C,11,75 BB 440 DATA 9,FE,6,9E,1,E8,6F,0,EB,DE,80,3E,95,1,50,77 DJ 450 DATA 18,B4,8,CD,10,3C,11,74,10,3C,19,75,1C,B0,D,AA DE 460 DATA FF,6,96,1,B0,A,EB,11,90,B0,D,B4,A,AB,83,6 AB 470 DATA 96,1,2,FE,6,9E,1,EB,AF,AA,FF,6,96,1,FE,6 LC 480 DATA 95,1,FE,6,9D,1,E8,2E,0,EB,BF,F8,BA,55,1,B4 CF 490 DATA 3C,B9,0,0,CD,21,73,9,BA,BC,1,E8,65,0,E8,83 LA 500 DATA 0,8B,D8,8B,E,96,1,BA,26,4,B4,40,CD,21,E8,21 HD 510 DATA 0,E8,5B,0,E8,6D,0,8A,36,9E,1,8A,16,9D,1,B4 CG 520 DATA 2,CD,10,C3,F8,BA,55,1,B0,2,B4,3D,CD,21,A3,9A LC 530 DATA 1,C3,8B,1E,9A,1,B4,3E,CD,21,C3,8A,D0,80,FA,D PH 540 DATA 74,8,E8,25,0,FE,6,9D,1,C3,B2,11,E8,1B,0,B2 JD 550 DATA D,E8,16,0,B2,A,E8,11,0,FE,6,9E,1,C6,6,9D ID 560 DATA 1,0,C3,50,B4,9,CD,21,58,C3,B4,2,CD,21,C3,B4 IG 570 DATA F,CD,10,88,3E,9C,1,B4,0,B0,2,CD,10,B4,5,B0 BF 580 DATA 0,CD,10,C3,CD,20