BASIC EDITOR II
by
Clayton Walnum
BASIC Editor II is a utility to help you enter BASIC program listings published in ANALOG Computing. To simplify the identification of errors, each program line is evaluated immediately after it's typed, eliminating the need for cumbersome checksum listings. When you've finished entering a program using BASIC Editor II, you can be certain it contains no typos.
An option is provided for those who wish to use standard BASIC abbreviations. Also, the program retains all Atari editing features. Finally, for those who prefer to type programs the conventional way, using the built-in editor, a post-processing mode is available. It allows you to check typing after the entire listing has been entered.
Typing in the
Editor
To create your copy of BASIC Editor II, follow the
instructions below- exactly.Disk version:
(1) Type in Listing 1, then verify your work with Unicheck (see Issue 39).
(2) Save the program to disk with the command SAVE "D: EDITORL1. BAS".
(3) Clear the computer's memory with the command NEW.
(4) Type in Listing 2, then verify your work with Unicheck.
(5) Run the program (after saving a backup copy) and follow all the on-screen prompts. A data file will be written to your disk.
(6) Load Listing 1 with the command LOAD "EDITORL1.BAS".
(7) Merge the file created by Listing 2 with the command ENTER "D: ML. DAT".
(8) Save the resultant program with the command LIST "D: EDITORII. LST ".
Cassette version:
(1) Type in Listing 1 and verify your work with Unicheck.
(2) Save the program to cassette with the command CSAVE. (Do not rewind the cassette.)
(3) Clear the computer's memory with the command NEW.
(4) Type in Listing 2 and verify your work with Unicheck.
(5) Run the program and follow the onscreen prompts. A data file will be written to your cassette.
(6) Rewind the cassette.
(7) Load Listing 1 with the command CLOAD.
(8) Merge the file created by Listing 2 with the command ENTER "C: "
(9) On a new cassette, save the resultant program with the command LIST "C: ".
Using the
Editor
Take a look at one of the BASIC program listings in
this issue. Notice that each program line is preceded by a two-letter
code. This code is the checksum for that line; it's not a part of the
program.To enter a program listing from the magazine, load BASIC Editor II with the ENTER command, and run it. You'll be asked if you wish to allow abbreviations (see your BASIC manual). If you do, type Y and press RETURN. Otherwise, type N.
Note: If you set BASIC Editor II to allow abbreviations, the program will run slightly slower.
Your screen will now be divided into two "windows:" The upper window will display each line after it's processed, as well as the checksum generated for that line. The lower window is where program lines are typed and edited.
When the program's waiting for input, the cursor will appear at the left margin of the typing window. Type a program line and press RETURN. The line will be evaluated and reprinted in the message window, along with the checksum generated.
If the checksum matches the one in the magazine, then go on to the next program line. Otherwise, enter the command E (edit) and press RETURN. The line you just typed will appear in the typing window, where you may edit it. When you think the line has been corrected, press RETURN, and it'll be reevaluated.
Note: You may call up any line previously typed, with the command E followed by the number of the line you wish to edit. For example, E230 will print Line 230 in the typing window. Do not attempt to edit any program lines numbered 32600 and higher. These lines fall within the BASIC Editor II program.
If you're using BASIC abbreviations, the two versions of the command E work slightly differently. The command E, without a line number, will call up the line exactly as you typed it. When you append the line number, the line will be printed in its expanded (unabbreviated) form.
Leaving the
Editor
You may leave BASIC Editor II at any time, by
entering either B (BASIC) or Q (quit). If you type B, the Editor will return you to
BASIC. Enter LIST to review
your work, if you wish. Note that lines 32600 and above are the Editor
program. Your work will appear before these lines. To return to the
Editor, type GOTO 32600.Type Q, and you'll be asked if you really want to quit. If you type Y, the Editor program will be erased from memory, and you may then save your work in any manner you like. If you type N, the Q command will be aborted.
Large listings
If the program you're entering is particularly long,
you may need to take a break. When you want to stop, type Q and press RETURN, then save your work to disk
or cassette. When you're ready to start again, load the program you
were working on, then load BASIC Editor II with the ENTER command. Type GOTO 32600, and you're back in
business.The post
processor
Many people may not want to use BASIC Editor II when
entering a program listing, preferring, instead, the Atari's built-in
editor. For that reason, BASIC Editor II will allow you to check and
edit your programs after they've been typed.To take advantage of this option, type any magazine program in the conventional manner, then save a copy to disk or cassette (just in case). With your typed-in program still in memory, load BASIC Editor II with the ENTER command, then type GOTO 32600.
Respond with N to the "abbreviations" prompt. When the Editor appears on your screen, enter the command P (post-process), and the first program line will appear in the typing window. Press RETURN to enter it into the Editor.
The line will be processed, and the checksum, along with the program line, will be printed in the upper window. If the checksum matches the one in the magazine, press RETURN twice, and the next line will be processed.
If you find you must edit a line, enter the command E, and the line will be moved back to the typing window for editing.
When the entire listing has been checked, you'll be asked if you wish to quit. Type Y and press RETURN. The Editor program will be removed from memory, and you may then save the edited program in any manner you wish.
Murphy's Law
Anyone who's been associated with computing knows
this is the industry Murphy had in mind. You may find that, after
typing a program with BASIC Editor II, it still won't run properly.
There are two likely causes for this.First, it may be that you're not following the program's instructions properly. Always read the article accompanying a program before attempting to run it. Failure to do so may present you with upsetting results.
Finally, though you can trust BASIC Editor II to catch your typos, it can't tell you if you've skipped some lines entirely. If your program won't run, make sure you've typed all of it. Missing program lines are guaranteed trouble.
One last word: Some people find it an unnecessary and nasty chore to type REM lines. I don't condone the omission of these lines, since they may be referenced within the program (a bad practice, but not unheard of). If you want to take chances, BASIC Editor II is willing to comply.
When you've finished entering a
program using BASIC Editor II. you
can be certain it contains no typos.
program using BASIC Editor II. you
can be certain it contains no typos.
Listing 1.
BASIC listing.
BASIC listing.
Blue indicates inverse video
32600 IF FL THEN 32616
32602 DIM L$(115),SV$(115),C2$(2),B$(1
15),M$(119),S$(98),E$(69),A$(l):FL=1:S
TMTAB=PEEK(136)+PEEK(137)*256
32604 GRAPHICS 0:POKE 710,0:P=0:ABR=0:
? "ALLOW ABBREVIATIONS";:INPUT A$:IF A
$="Y" OR A$="y" THEN ABR=1
32606 B$(1)=" ":B$(115)=" ":B$(2)=B$
32616 OPEN #17,4,0,"E:":LS=" ":GOSUB 3
2662:START=0
32618 POKE 766,1:POKE 83,39:POSITION 1
,3:IF LEN(L$)<39 THEN ? L$:GOTO 32624
32620 IF LEN(L$)<77 THEN ? L$(1,38):?
L$(39,LEN(L$)):GOTO 32624
32622 ? L$(1,38):? L$(39,76):? L$(77,L
EN(L$))
32624 POKE 752,0:POKE 766,0:POKE 559,3
4:POKE 82,1:POKE 83,38:POSITION 8,10:?
" ";:INPUT #17;L$:POKE 766,1
32626 IF (L$="P" OR L$="p") AND START=
0 THEN P=1:L$=""
32628 IF L$="E" OR L$="e" THEN E=1:POS
ITION 1,10:? SV$ GOTO 32624
32530 IF L$="Q" OR L$="q" (HEN 32690
32632 IF L$="" AND P=1 THEN 32686
32634 IF L$="" THEN 32624
32636 IF L$="B" OR L$="b" THEN GRAPHIC
S 0:? "TYPE 'GOTO 32600' TO CONTINUE":
END
32638 IF L$(1,1)="E" OR L$(1,1)="e" TH
EN E=1:TRAP 32624:EL=VAL(L$(2)):POSITI
ON 1,9:LIST EL:GOTO 32624
32640 SV$=L$:TRAP 32624:X=VAL(L$)
32642 START=1:IF P AND NOT E THEN 326
52
32644 GOSUB 32674:IF NOT ABR OR P THE
N 32652
32646 POKE 766,0:? CHR$(125):POSITION
0,3:L=VAL(L$):LIST L:? :? :? "CONT":L$
=B$
32648 POSITION 0,0:POKE 842,13:STOP
32650 POKE 842,12:A=USR(ADR(S$),ADR(L$
),4):L$=L$(1,A)
32652 CHKSUM=USR(ADR(M$),ADR(L$),LEN(L
$)):CHKSUM=CHKSUM+PEEK(1542)*65536
32654 CMK=CHKSUM-(INT(CHKSUM/676)*676)
:HI=INT(CHK/267:LO=CHK-(HI*267:C2$(1)=
CMR$(HI+65):C2$(2)=CHR$(LO+65)
32656 IF NOT P OR E THEN E=0:GOSUB 32
662:IF NOT P THEN 32660
32658 POKE 83,39:POKE 752,1:FOR X=3 TO
5:POSITION 1,X:? B$(1,38):POSITION 1,
X+7:? B$(1,38):NEXT X:POKE 83,38
32660 POKE 766,1:POKE 83,38:POSITION 6
,7:? C2$:POKE 752,0:GOTO 32618
32662 GOSUB 32702:POKE 766,0:POKE 752,
1:? "":POKE 82,1:DL=PEEK(560)+256*PEE
K(561)+4
32664 POKE DL-1,70:POKE DL+2,6:POKE DL
+3,112:POKE DL+4,112:POKE DL+5,112:POK
E DL+13,112:POKE DL+14,112
32666 POKE DL+22,112:POKE DL+23,112:P0
KE DL+24,65:POKE DL+25,PEEK(560):POKE
DL+26,PEEK(561):POKE 83,39
32668 POSITION 20,0:? " basic editor
ii ":POSITION 0 7:? " TYP
ING WINDOW "
32670 POSITION 0,1:? " MESS
AGE WINDOW ":POSITION 1,7
:? "CODE:";
32672 POKE 559,34:RETURN
32674 GRAPHICS 0:POKE 559,0:POKE 766,1
:POKE 82,0:POKE 83,391POSITION 0,3:? L
$:? :? :? :? "CONT":POSITION 0,0
32676 POKE 842,13:STOP
32678 POKE 842,12:TRAP 32682,A=USR(ADR
(E$),VAL(L$)):ZF A=4 THEN POP :GOTO 32
682
32680 RETURN
32682 GOSUB 32662:SOUND 0,75,10,8:FOR
X=1 TO 20:NEXT X:SOUND 0,0,0,0:POSZTIO
N 1,3:? "SYNTAX ERROR!":POKE 766,1
32684 POKE 83,38:POSITION 1,10:? SV$:G
OTO 32624
32686 LINE=PEEK(STMTAB)+PEEK(STMTAB+1)
*256:IF LINE>32599 THEN 32690
32668 OFS=PEEK(STMTAB+2):STMTAB=STMTAB
+OFS:POSITION 1,9:LIST LINE:GOTO 32624
32690 POKE 766,0:POSITION 1,10:? "READ
Y TO QUIT";:INPUT A$:IF A$<>"Y" THEN P
OSITION 1,10:? B$(1,38):GOTO 32624
32692 GRAPHICS 0:? :? :? :FOR X=32600
TO 32636 STEP 2:? X:NEXT X:? "CONT":PO
SITION 0,0:POKE 842,13:STOP
32694 POKE 842,12:GRAPHICS 0:? :? :? :
FOR X=32638 TO 32674 STEP 2:? X:NEXT X
:? :? "CONT":POSITION 0,0
32696 POKE 842,13:STOP
32698 POKE 842,12:GRAPHICS 0:? :? :? :
FOR X=32676 TO 32702 STEP 2:? X:NEXT X
:? :? "POKE 842,12":POSITION 0,0
32700 POKE 842,13:STOP
32702 POKE 16,112:POKE 53774,112:RETUR
N
CHECKSUM DATA.
(see issue 39's Unicheck)
(see issue 39's Unicheck)
32600 DATA 6,665,923,757,809,171,225,8
98,532,499,910,267,912,144,735,8453
32638 DATA 97,358,230,693,706,878,317,
127,36,597,238,258,182,438,168,5315
32668 DATA 864,953,472,385,887,724,72,
687,908,736,625,612,672,184,891,9672
32698 DATA 6,856,85,949
Listing 2.
BASIC listing.
BASIC listing.
10 DIM L$(120),ML$(119),A$(1)
20 GRAPHICS 0:POKE 710,0:? "DISK OR CA
SSETTE";:INPUT A$:IF A$<>"C" AND A$<>"
D" THEN 20
30 IF A$="C" THEN 50
40 ? "PLACE FORMATTED DISK IN DRIVE":?
"THEN PRESS RETURN":INPUT L$:OPEN #1,
8,0,"D:ML.DAY:":GOTO 60
50 ? :? "READY CASSETTE, PRE55 RETURN"
;:INPUT L$:OPEN #1,8,0,"C:"
60 L$="32608 M$(1)=":L$(13)=CHR$(34)
70 N=119:GOSUB 130:L$(14)=ML$(1,58):L$
(LEN(L$)+1)=CHR$(34):? #1;L$
80 L$(1)="32610 M$(59)=":L$(14)=CHR$(3
4):L$(15)=ML$(59):L$(LEN(L$)+1)=CHR$(3
4):? #1,L$
90 L$(1)="32612 S$=":L$(10)=CHR$(34)
100 ML$="":N=98:GOSUB 130:L$(ll)=ML$:L
$(LEN(L$)+l)=CHR$(34):? #1;L$
110 L$(1)="32614 E$=":L$(10)=CHR$(34)
120 ML$="":N=69:GOSUB 130:L$(ll)=ML$;L
$(LEN(L$)+1)=CHR$(34):? #1;L$:END
130 FOR X=1 TO N:READ A:ML$(X)=CMR$(A)
:NEXT X:RETURN
140 DATA 104,104,133,204,104,133,203,1
04,104,133,205,169,0,141,3,6,141,2,6,1
41,4,6,141,5,6
150 DATA 141,6,6,238,3,6,32,68,218,172
,2,6,177,203,133,212,32,170,217,32,182
,221,32,66,218
160 DATA 173,3,6,133,212,32,170,217,32
,219,218,32,210,217,165,212,141,0,6,16
5,213,141,1,6,24
170 DATA 173,0,6,109,4,6,141,4,6,173,1
,6,109,5,6,141,5,6,144,3,238,6,6,238,2
180 DATA 6,172,2,6,196,205,208,176,173
,4,6,133,212,173,5,6,133,213,96
190 DATA 104,104,133,204,104,133,203,1
04,104,141,255,6,169,0,133,213,216,165
,88,133,205,165,89,133,206
200 DATA 174,255,6,24,165,205,105,40,1
33,205,144,2,230,206,202,208,242,160,0
,177,205,201,64,144,18
210 DATA 201,96,144,19,201,128,144,18,
201,192,144,6,201,224,144,7,176,8,24,1
05,32,144,3,56,233
220 DATA 64,145,203,200,192,114,240,2,
208,215,177,283,201,32,208,3,136,208,2
47,200,132,212,96
230 DATA 104,104,141,254,6,104,141,253
,6,169,0,133,213,216,165,136,133,205,1
65,137,133,206,160,0,177
240 DATA 205,205,253,6,208,8,200,177,2
05,205,254,6,240,15,160,2,177,205,24,1
01,205,133,205,144,228
250 DATA 230,206,176,224,160,4,177,205
,201,55,240,4,160,0,240,0,132,212,96
CHECKSUM DATA.
(see issue 39's Unicheck)
10 DATA 203,265,465,844,294,973,652,27
0,978,797,278,275,835,209,301,7639
50 DATA 355,94,254,420,935,840,580,41
,974,564,5435