10REM"
20REM"
40REM" This program is not finished
50REM" yet, although it is just a
60REM" tidying up job required. You
70REM" have persevered well already,
80REM" now see if you can work out
90REM" what this program does, and
100REM" how to use it!
110REM" ------------------------------
--
120REM" This program is not yet PD
as
130REM" it is not yet totally finish
ed
140REM" I haven't had time to debug
by
150REM" use yet. So please hang on
to
160REM" it for the mo! Appreciated, CJ
R.
170REM" ------------------------------
--
180DEFFNS:="chains"
190IFPAGE<>&1900:PRINT"CHANGE TO &1900
":VDU7:END:REM PAGE=&1900:CHAIN"1staid"
200ONERROR:CLOSE#0:REPORT:PRINTERL:END
210MODE7:HIMEM=&2900:REM START OF DATA
220PROCinit
230REPEAT
240CLS:PROCd("Chains. By C.J.Richardso
n.")
250PRINT':PROCd("Choose:"):PRINT'
260PROCd("1. Add a new statement.")
270PROCd("2. Add addresses to choices.
")
280PROCd("3. Save/load data.")
290PROCd("4. Play.")
300PROCd("5. Find top of data.")
310A$=GET$:CLS
320IFA$="1"PROCstatement
330IFA$="2"IFP%<>HIMEM+2:PROCchoice
340IFA$="3"PROCsave`load
350IFA$="4"PROCtestout
360IFA$="5"PROCftop
370UNTILFALSE
380DEFPROCd(A$):PRINT"
390DEFPROCinit
400U%=0:P%=HIMEM+2:$P%="|****"
410ENDPROC
420DEFPROCstatement
430PROCd("Input new statement to &"+ST
R$÷P%)
440INPUT''$P%:IF LEFT$($P%,4)="*LO." $
P%="!!"+$P%
450$P%="|"+$P%
460P%=P%+LEN$P%+1
470L%=0:REPEAT
480PROCd("| To finish. Any other for m
ore.")
490A$=GET$
500IFA$<>"|":PROCd("Enter choice "+STR
$L%):INPUT $P%:$P%="!!"+$P%:P%=P%+LEN$P%
+1:L%=L%+1
510UNTILA$="|"ORL%=10:$P%="|****"
520ENDPROC
530DEFPROCchoice:H%=HIMEM+1
540PROCsrch:REPEAT
550REPEAT:A$=GET$:UNTILVALA$>0ANDVALA$
<4
560IFA$="1"PROCfindadd:A$=""
570IFA$="2"PROCsrch
580UNTILA$="3":A$=""
590ENDPROC
600DEFPROCt:CLS:PROCd("Tie choice to s
tatement."):PROCd("1. Tie."):PROCd("2. F
ind next choice."):PROCd("3. Back to men
u."):ENDPROC
610DEFPROCsrch:IFH%>=P%H%=HIMEM+1
620REPEAT:H%=H%+1:IF?H%=ASC"|"CLS:PROC
t:B$=$(H%+1):IFINSTR(B$,"*LO.")B$=MID$(B
$,3)
630UNTIL?(H%-1)=ASC"!"AND?H%=ASC"!" OR
H%>P%:H%=H%+1
640IFB$<>"****" PRINTTAB(0,9);B$'$H%;S
PC200 ELSE PROCd("None free!")
650ENDPROC
660DEFPROCfindadd:CLS:PROCd("Choose st
atement to go with:"):PRINTB$'$H%:PROCd(
"1. Find next free choice."):PROCd("2. T
ie to this."):PROCd("3. Quit.")
670IFLEFT$($H%,4)="*LO." U%=1:OSCLI"SA
. TEMP "+STR$÷HIMEM+" "+STR$÷(P%+1):OSCL
I"LO."+MID$($H%,5)+" "+STR$÷HIMEM
680T%=HIMEM+3:PRINTTAB(0,12);$T%
690REPEAT:A$=GET$
700IFA$="1"IFT%<P%:REPEAT:T%=T%+1:UNTI
L?(T%-1)=ASC"|"AND?(T%-2)=13 ORT%=P%:IF
T%=P% T%=HIMEM+3
710IFINSTR($T%,"*LO.")T%=T%+2
720PRINTTAB(0,12)$T%;SPC(200)
730UNTILA$="2"ORA$="3":IFA$="3" ENDPRO
C
740IFU%=1:OSCLI"LO.TEMP "+STR$÷HIMEM:U
%=0
750?(H%-2)=T%MOD256
760?(H%-1)=T%DIV256
770PROCt
780ENDPROC
790DEFPROCsave`load
800?HIMEM=P%MOD256:?(HIMEM+1)=P%DIV256
810PROCd("Load or Save? L/S"):*.
820REPEAT:A$=GET$:UNTILA$="L"ORA$="S":
PROCd(A$)
830PROCd("Enter Filename"):INPUT F$:IF
A$="L":OSCLI"LO."+F$+" "+STR$÷HIMEM ELS
E OSCLI"SA."+F$+" "+STR$÷HIMEM+" "+STR$÷
(P%+6)
840P%=?HIMEM+?(HIMEM+1)*256
850ENDPROC
860DEFPROCftop:PROCd("Please wait. Fin
ding top")
870P%=HIMEM
880REPEATP%=P%+1:UNTIL$P%="****":P%=P%
-1
890?HIMEM=P% MOD 256
900?(HIMEM+1)=P% DIV 256
910ENDPROC
920DEFPROCtestout
930X%=HIMEM+3
940REPEAT:CLS:PROCd("Enter 0 - 9")
950A%=&70:Z%=99
960REPEAT
970IF INSTR($(X%-2),"*LO.") I%=X%:X%=?
(X%-4)+?(X%-3)*256:OSCLI $(I%-2)+" "+STR
$÷HIMEM
980VDU?X%:X%=X%+1
990IF?X%=13:IFA%=&70:PRINT'
1000IF?X%=13:VDU10,13:PRINT" ";STR$((A%
-&70)/2);" ";:?A%=?(X%+1):?(A%+1)=?(X%+2
):IF?(X%+1)<>ASC"|" X%=X%+3:A%=A%+2
1010UNTIL?(X%)=ASC"|"AND?(X%-1)=13:VDU3
2,32
1020REPEAT:A%=A%+1:?A%=0:UNTIL A%=&85
1030REPEAT:B%=VALGET$:X%=?(B%*2+&70)+?(
B%*2+&71)*256:UNTILX%>&100
1040UNTILFALSE
1050ENDPROC