Dunnington Flowcharter

(Editor’s NOTE: This article would be worthwhile reading if it didn’t contain anything but the material on programming above line 9999.)

My version of the BASIC program uses 1004 bytes after deleting all lines less than 9000 and ENTERing CLEAR in accordance with the CHALLENGE instructions.

Our Editor did not like the treatment of the NEW command and as I agree, I changed this to use the start stop symbol and dropped the program continuation line and arrow. I also changed the GOSUB command treatment to add the program continuation line and arrow. The treatment of the RETURN command was changed to use the circle with an arrow to the side.

To save four bytes for each line number used, I combined lines 9903 & 9904; 9906 & 9907; 9912 & 9913; 9925 & 9926; 9927 & 9928; 9930 & 9931; 9936, 9937 & 9938; 9940 & 9941; 9946 & 9947.

LET e=22 in line 9946 was deleted as the variable e was not used in the program. I deleted the INPUT ;: in line 9944 as useless. Because this is a utility program, to be MERGEd, I feel that the use of color is a waste of memory. Therefore, I deleted BRIGHT SGN PI in line 9942. To save the eyesight of the bifocal group, of which I am one, Caps were used whenever possible. I normally program with the CAPS LOCK on.

A single letter variable occupies six and a double letter variable seven bytes in the VARS area. The rules of the CHALLENGE do not state that the program must be operable after CLEAR has been ENTERed which clears the VARS area, deleting all of the variables, string variables and arrays. By assigning all of the numerical constants in the program to a single or double letter variable entered either as a direct command or in lines to be deleted after RUNning the line, you can save a lot of memory in the PROG area of the computer. It then requires only one or two bytes in the program area for any numerical constant including GO TOs and GOSUBs. When the program is SAVEd the assigned variables are also saved, even without any lines. After LOADing the variables, the program lines can be MERGEd to form the complete program to be SAVEd. Assigning the PRINT strings, lines 9940, 9942, 9948 to string variables, saves some more bytes in the program area.

I assigned the variables as follows:

TABLE OF VARIABLES

E =-PI   : V =+16  : AL=227  : AZ=253   : BN=10020
H = 0    : W =+19  : AM=230  : BA=254   : BO=10021
I =+1    : Z =+22  : AN=231  : BB=256   : BP=10024
J =+2    : AA=-24  : AO=232  :          : BQ=10025
K =+3    : AB=+26  : AP=234  : BD=10000 : BR=10026
M =+4    : AC=-28  : AQ=235  : BE=10001 : BS=10029
N =-4    : AD=-32  : AR=236  : BF=10003 : BT=10030
O =+5    : AE=+34  : AS=237  : BG=10008 : BU=10031
P =-7    : AF=+58  : AT=241  : BH=10010 : BV=10032
Q =-8    : AG=+64  : AU=242  : BI=10011 : BW=10035
R =+8    : AH=130  : AV=243  : BJ=10016 : BX=10036
S =+12   : AI=175  : AW=247  : BK=10017 : BY=10038
T =+13   : AJ=203  : AX=249  : BL=10018 : BZ=23635
U =+14   : AK=226  : AY=250  : BM=10019 : CA=23636
A$="""c"" TO CONTINUE ;""p"" TO PRINT"
B$=" END OF BASIC PROGRAM"
C$="  : "

When developing utility programs in BASIC designed to be MERGEd with other programs, I like to use line numbers 10000 and above. This way there will be no conflict of numbers between the two programs. Line numbers of 10000 to 10999 are represented by the computer as :ddd where the colon is ten thousand and each d is a digit. Line numbers of 10000 or above can not be ENTERed directly but must be POKEd into the first two addresses of a stored program line, the High Byte then the Low Byte.

The High Byte for 10000=INT (10000/256)=39

The Low Byte for 10000=10000-256*HB=16

The line can not be EDITed after it has been changed. GO TO or GO SUB 10000 etc can be ENTERed or used in a program line and will operate normally as will RETURN.

In the program area, a numerical value of 10000 would use 11 bytes. The substitution of VAL “10000” uses eight bytes. Representing 10000 by a double letter variable uses only two bytes in the program area.

To program my version of “Flowchart” using a tape recorder (see NOTE below):

1. Type in, RUN, and SAVE the “Assignment of Variables” program. Do not delete the lines before SAVEing as you may have an error that will show up later.

2. Use NEW to clear the computer.

3. Type in and SAVE the combined “Renumber and Preliminary Flowchart” program. DO NOT RUN BEFORE SAVEing.

4. Enter RUN, then delete lines 420 to 510 and enter CLEAR.

5. MERGE the “Assignment of Variables” program and delete lines 1, 2, and 3.

6. SAVE the final version of “Flowchart”.

To test the program:

1. Turn the computer off and then on. 2. Type in the Demo lines 1 through 410. 3. MERGE the final version of “Flowchart”, and CLS. 4. Use GO TO 10000 to operate the program. 5. If you inadvertently use RUN or CLEAR, just MERGE the final version of “Flowchart” again.

NOTE: The Larken Disk Operating System (LKDOS) V3 does not load the variables when MERGE is used. In programming step 5 after MERGEing the Assignment of Variables, you would have to add line 4 STOP and then RUN the program and delete lines 1 to 4. In testing the program step 2 you would SAVE the Demo lines program, after typing them in. In step 3 you would LOAD the final version of Flowchart and MERGE the Demo lines.

   1 REM Assignment of Variables
by EARL DUNNINGTON
[address omitted]
[phone number omitted]
2 LET E=-PI: LET H=0: LET I=1
: LET J=2: LET K=3: LET M=4: LET
N=-4: LET O=5: LET P=-7: LET Q=
-8: LET R=8: LET S=12: LET T=13:
LET U=14: LET V=16: LET W=19: L
ET Z=22: LET AA=-24: LET AB=26:
LET AC=-28: LET AD=-32: LET AE=3
4: LET AF=58: LET AG=64: LET AH=
130: LET AI=175: LET AJ=203: LET
AK=226: LET AL=227: LET AM=230:
LET AN=231: LET AO=232: LET AP=
234: LET AQ=235: LET AR=236: LET
AS=237: LET AT=241: LET AU=242:
LET AV=243: LET AW=247: LET AX=
249: LET AY=250: LET AZ=253: LET
BA=254: LET BB=256
3 LET BD=10000: LET BE=10001:
LET BF=10003: LET BG=10008: LET
BH=10010: LET BI=10011: LET BJ=
10016: LET BK=10017: LET BL=1001
8: LET BM=10019: LET BN=10020: L
ET BO=10021: LET BP=10024: LET B
Q=10025: LET BR=10026: LET BS=10
029: LET BT=10030: LET BU=10031:
LET BV=10032: LET BW=10035: LET
BX=10036: LET BY=10038: LET BZ=
23635: LET CA=23636: LET A$="""c
"" TO CONTINUE ;""p"" TO PRINT":
LET B$=" END OF BASIC PROGRAM":
LET C$=" : "

ASSIGNMENT OF VARIABLES PROGRAM

 420 REM Renumber and Preliminar
y Flowchart program
430 LET START=(PEEK 23627+256*P
EEK 23628)-1005: REM Address of
byte before line 9901
440 LET HIGHBYTE=39: LET LOWBYT
E=16: REM 10000=39*256+16
450 FOR N=START TO START+1004-1
: REM 1004 is number of bytes in
flowchart
460 IF PEEK N<>13 THEN GO TO 5
00: REM if not end of line chara
cter go to next address
470 POKE N+1,HIGHBYTE: POKE N+2
,LOWBYTE: REM Poke new line numb
er
480 LET LOWBYTE=LOWBYTE+1: REM
advance new line number by one
490 LET N=N+5: REM Skip over ad
dresses of line number and lengt
h of line
500 NEXT N
510 STOP
9901 LET A=PEEK BZ+BB*PEEK CA: L
ET C=H: LET Y=AI: LET X=AH
9903 LET L=PEEK (A+I)+BB*PEEK A:
LET A=A+M: IF L>=BD THEN GO TO
BX
9905 PRINT L;TAB O;CHR$ PEEK A:
LET C=C+J: PRINT
9906 PLOT X,Y: LET B=PEEK A: IF
B=AK OR B=AM OR B=AP OR B=AU THE
N GO TO BL
9908 IF B>AL AND B<AN OR B=AO OR
B=AQ OR B=AT OR B=AW OR B=AX OR
B=AZ THEN GO TO BM
9909 IF B=AV OR B=AY THEN GO TO
BN
9910 IF B=AR OR B=AS OR B=BA THE
N GO TO BQ
9911 DRAW V,H: DRAW N,Q: DRAW AC
,H: DRAW M,R: DRAW S,H
9912 LET Y=Y-R: IF B=AK OR B=AR
OR B=AM OR B=BA THEN GO TO BH
9914 PLOT X,Y: DRAW H,P: DRAW M,
M: DRAW N,N: DRAW N,M
9915 LET Y=Y-R
9916 LET B=PEEK A: IF B=AE THEN
GO SUB BY
9917 IF B=U THEN LET A=A+M
9918 IF B=T THEN GO TO BJ
9919 IF B=AF THEN GO TO BS
9920 LET A=A+I: GO TO BI
9921 IF C=Z THEN GO TO BU
9922 LET A=A+I: GO TO BE
9923 DRAW S,H: DRAW M,Q,E: DRAW
AA,H: DRAW N,R,E: DRAW S,H: GO T
O BG
9924 DRAW V,H: DRAW H,Q: DRAW AD
,H: DRAW H,R: DRAW V,H: GO TO BG
9925 DRAW R,N: DRAW R,H: DRAW N,
M: DRAW M,N: DRAW N,N: DRAW M,M:
DRAW Q,H: DRAW Q,N: DRAW Q,M: D
RAW R,M: IF B=AV THEN GO TO BP
9927 LET A=A+I: LET F=PEEK A: IF
F=U THEN LET A=A+M
9929 IF F<>AJ THEN GO TO BO
9930 LET A=A+I: LET F=PEEK A: PR
INT AT C-J,W;CHR$ F: PRINT : IF
F=AR OR F=AS THEN GO TO BR
9932 GO TO BG
9933 CIRCLE X,Y-M,M: PLOT X+M,Y-
M: DRAW AG,H: DRAW N,M: DRAW M,N
: DRAW N,N: PLOT X,Y: IF B=BA TH
EN GO TO BG
9934 LET A=A+I: LET F=PEEK A
9935 IF F<>U THEN GO TO BR
9936 LET A=A+K: LET G=PEEK A+BB*
PEEK (A+I): PRINT AT C-J,AB;G: P
RINT : GO TO BG
9939 IF C=Z THEN GO TO BU
9940 LET A=A+I: PRINT C$;CHR$ PE
EK A: PRINT : LET C=C+J: GO TO B
F
9942 PRINT #H;A$: PAUSE H
9943 IF INKEY$="c" THEN GO TO B
W
9944 IF INKEY$="p" THEN COPY :
GO TO BW
9945 GO TO BV
9946 CLS : LET D=H: LET C=D: LET
X=AH: LET Y=AI: IF PEEK A=AF TH
EN GO TO BT
9948 IF L>=BD THEN PRINT #H;B$:
PAUSE H: STOP
9949 GO TO BK
9951 LET A=A+I: LET B=PEEK A: IF
B=AE THEN RETURN
9952 GO TO BY

RENUMBER AND PRELIMINARY FLOWCHART PROGRAM

   1 CLS
10 IF 5>1 THEN GO TO 9000
20 FOR f=1 TO 3: PRINT 5: NEXT
f
30 GO SUB 400
40 LOAD ""
50 PRINT 1
60 STOP
70 LOAD "a"
80 SAVE "a" LINE 10: BEEP .3,1
2: BEEP 1,12: VERIFY "a": BEEP .
3,16: BEEP 1,16
90 NEW
100 LIST 10
350 STOP
400 PRINT 123: RETURN
410 STOP
:000 LET A=PEEK BZ+BB*PEEK CA: L
ET C=H: LET Y=AI: LET X=AH
:001 LET L=PEEK (A+I)+BB*PEEK A:
LET A=A+M: IF L>=BD THEN GO TO
BX
:002 PRINT L;TAB O;CHR$ PEEK A:
LET C=C+J: PRINT
:003 PLOT X,Y: LET B=PEEK A: IF
B=AK OR B=AM OR B=AP OR B=AU THE
N GO TO BL
:004 IF B>AL AND B<AN OR B=AO OR
B=AQ OR B=AT OR B=AW OR B=AX OR
B=AZ THEN GO TO BM
:005 IF B=AV OR B=AY THEN GO TO
BN
:006 IF B=AR OR B=AS OR B=BA THE
N GO TO BQ
:007 DRAW V,H: DRAW N,Q: DRAW AC
,H: DRAW M,R: DRAW S,H
:008 LET Y=Y-R: IF B=AK OR B=AR
OR B=AM OR B=BA THEN GO TO BH
:009 PLOT X,Y: DRAW H,P: DRAW M,
M: DRAW N,N: DRAW N,M
:010 LET Y=Y-R
:011 LET B=PEEK A: IF B=AE THEN
GO SUB BY
:012 IF B=U THEN LET A=A+M
:013 IF B=T THEN GO TO BJ
:014 IF B=AF THEN GO TO BS
:015 LET A=A+I: GO TO BI
:016 IF C=Z THEN GO TO BU
:017 LET A=A+I: GO TO BE
:018 DRAW S,H: DRAW M,Q,E: DRAW
AA,H: DRAW N,R,E: DRAW S,H: GO T
O BG
:019 DRAW V,H: DRAW H,Q: DRAW AD
,H: DRAW H,R: DRAW V,H: GO TO BG
:020 DRAW R,N: DRAW R,H: DRAW N,
M: DRAW M,N: DRAW N,N: DRAW M,M:
DRAW Q,H: DRAW Q,N: DRAW Q,M: D
RAW R,M: IF B=AV THEN GO TO BP
:021 LET A=A+I: LET F=PEEK A: IF
F=U THEN LET A=A+M
:022 IF F<>AJ THEN GO TO BO
:023 LET A=A+I: LET F=PEEK A: PR
INT AT C-J,W;CHR$ F: PRINT : IF
F=AR OR F=AS THEN GO TO BR
:024 GO TO BG
:025 CIRCLE X,Y-M,M: PLOT X+M,Y-
M: DRAW AG,H: DRAW N,M: DRAW M,N
: DRAW N,N: PLOT X,Y: IF B=BA TH
EN GO TO BG
:026 LET A=A+I: LET F=PEEK A
:027 IF F<>U THEN GO TO BR
:028 LET A=A+K: LET G=PEEK A+BB*
PEEK (A+I): PRINT AT C-J,AB;G: P
RINT : GO TO BG
:029 IF C=Z THEN GO TO BU
:030 LET A=A+I: PRINT C$;CHR$ PE
EK A: PRINT : LET C=C+J: GO TO B
F
:031 PRINT #H;A$: PAUSE H
:032 IF INKEY$="c" THEN GO TO B
W
:033 IF INKEY$="p" THEN COPY :
GO TO BW
:034 GO TO BV
:035 CLS : LET D=H: LET C=D: LET
X=AH: LET Y=AI: IF PEEK A=AF TH
EN GO TO BT
:036 IF L>=BD THEN PRINT #H;B$:
PAUSE H: STOP
:037 GO TO BK
:038 LET A=A+I: LET B=PEEK A: IF
B=AE THEN RETURN
:039 GO TO BY

MERGEd Demo and Final Version of FLOWCHART PROGRAM

NOTE: use CLS and GO TO 10000 to operate this program

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.