Artificial Intelligence



Eliza


Artificial intelligence is a goal which has not yet been achieved. Certainly, programs which enable computers to exhibit behaviour which could conceivably be classed as intelligent have been written, but the 'intelligence' has been limited and effective only within a severely restricted domain. That is, the computer appears to be brainy, but only if you limit the environment within which it has to demonstrate those brains.
   This is the kind of 'intelligence' demonstrated by our next program, a variation of one of the best-known and popular artificial intelligence programs ever written. In Eliza, the computer takes on the role of a psychiatrist and apparently carries on a conversation. Eliza was originally developed in the mid-1960s by Joseph Weizenbaum. He was attempting to produce a program which would caricature a Rogerian psychoanalyst. It has been suggested that Weizenbaum regrets his work on the program. It is not hard to see why.
   In the euphoric days after the program was first made public, wild claims were made that it was only a matter of time before computers could take over the role of 'mind-doctors'. Further, the Eliza success, said some incautious observers, paved the way for genuinely intelligent computers.
   Weizenbaum did not believe it for a moment. He writes that he was amazed at the beginning - and continues to be amazed - at the reaction to the program. Written in the computer language LISP at the Massachusetts Institute of Technology, the program could be accessed from any one of a number of time-sharing terminals dotted around the campus. Weizenbaum reports that he was very interested to see the program being accessed time and time again late at night, as though troubled students really were discussing their problems with the program. Furthermore, the accesses were all very long. The computer log showed some people were hooked into Eliza for over an hour at a time.
   Weizenbaum's secretary had worked closely with him over the six months or so it took to produce the program, and she knew as well as he how it worked, scanned a person's speech for 'key words' (such as dream and friends) and then choosing a suitable reply from a bank of responses. Other words from a user's sentence could be incorporated, sentences could be 'turned around' (so 'I am happy because of the weather' could be simply fed back to the user as either 'Why are you happy because of the weather' or just a statement of the form 'You are happy because of the weather'. What does this suggest to you?'), and a number of other replies (such as 'That is interesting, please go on') could be used if no key word was recognized.
   Despite the secretary's familiarity with the program Weizenbaum noticed that if he walked into the office when she was accessing the program, she became embarrassed and refused to let him see the printout. Futher, his suggestion that it would be interesting to hook up a printer to the main body of the computer to record the students' late-night conversations with the program, was greeted with horror, as though he were suggesting a kind of electronic peeping-Tom activity. (If you'd like to look further into Weizenbaum's work on artificial intelligence, you might be interested in his book Computer Power and Human Reason, W. H. Freeman and Co., San Fancisco, 1976.)


Here's our BBC Micro Eliza in action, talking to Ian:

Hello and welcome. I am your friendly
BBC Computer.

Before we start, just to get on good
terms,it may be wise for you to tell
me your name.
?IAN
Well what a fabulous name Ian is.
Its a pleasure to have you talking to
me IAN.

?I HAVE A PROBLEM
IAN,you have a problem

?YES I HAVE A PROBLEM
You seem quite certain. Why is this so?

?BECAUSE I HAVE COME TO YOU FOR SOME HEL
P
What makes you think I know any better?

?I THOUGHT THAT BEING A COMPUTER YOU WOU
LD BE ABLE TO
Why do you mention computers?

?BECAUSE YOU ARE ONE
IAN,What makes you think I am one

?WELL YOU ARE
What makes you think I am


This is a little later in the same 'conversation':

?LETS NOT GO THROUGH THIS AGAIN
IAN,Why are you being negative

?SORRY
IAN,Why are you apologizing?

?ARE YOU VERY CLEVER
IAN,Why are you interested in whether
or not I am very clever

?I JUST THOUGHT THAT IT MAY HELP
What makes you think I know any better?

?I DONT KNOW
you dont know

?YEP I DONT
you dont

?WHY BOTHER I ASK MYSELF
What is it that you really want to
know?

?DO COMPUTERS CREAM?
IAN,Why did you bring up the subject
of dreams?

?BECAUSE THATS MY PROBLEM
Have you seen a Doctor about this?

?NO BECAUSE I WANTED TO TALK TO YOU ABOU
T IT FIRST
People who want don't get.


And here's the listing, so BBC Eliza can help you solve your problems:

   10 REM      ELIZA
   20  
   30 MODE 7
   40 ON ERROR GOTO 1280
   50 PROC_INIT
   60 PROC_INTRO
   70 REPEAT
   80   PROC_INPUT
   90   ANSWER$=FN_REPLY
  100   PROC_JUSTIFY(ANSWER$)
  110   PRINT
  120   UNTIL BYE
  130 PROC_QUIT
  140 END
  150 DEF PROC_INTRO
  160 PRINT''
  170 PROC_JUSTIFY("Hello and welcome.I 
am your friendly BBC[fs0]Computer.")
  180 PRINT
  190 PROC_JUSTIFY("Before we start,just
 to get on good terms,it may be wise for
 you to tell me your name.")
  200 INPUT name$
  210 IF LEFT$(FN_UCASE(name$),3)="IAN" 
THEN PROC_JUSTIFY("Well what a fabulous 
name Ian is.")
  220 PROC_JUSTIFY("Its a pleasure to ha
ve you talking to me "+name$+".")
  230 PRINT
  240 ON ERROR IF ERR=17 THEN 130 ELSE 1
280
  250 BYE=FALSE
  260 ENDPROC
  270 DEF PROC_INPUT
  280 LOCAL QUESTION$
  290 INPUT QUESTION$
  300 reply$=FN_CONVERT(QUESTION$)
  310 REPLY$=FN_UCASE(reply$)
  320 TEMP$=REPLY$
  330 ENDPROC
  340 DEF FN_UCASE(S$)
  350 LOCAL L%,C$,R$
  360 R$=""
  370 FOR L%=1 TO LEN(S$)
  380 C$=MID$(S$,L%,1)
  390 IF C$>="a" AND C$<="z" THEN C$=CHR
$(ASC(C$)-32)
  400 R$=R$+C$
  410 NEXT
  420 =R$
  430 DEF FN_CONVERT(S$)
  440 IF S$="" THEN =" "
  450 LOCAL L%,P%,C$,T$
  460 T$=" "
  470 P%=0
  480 REPEAT P%=P%+1
  490   UNTIL MID$(S$,P%,1)<>" "
  500 FOR L%=P% TO LEN(S$)
  510 C$=MID$(S$,L%,1)
  520 IF C$>="A" AND C$<="Z" THEN C$=CHR
$(ASC(C$)+32)
  530 T$=T$+C$
  540 NEXT
  550 IF LEFT$(T$,8)=" beause" THEN T$=M
ID$(T$,9)
  560 =T$+"  "
  570 DEF FN_REPLY
  580 LOCAL R$,Z%,D%,FLAG
  590 IF RND(10)<3 THEN R$=name$+"," ELS
E R$=""
  600 IF REPLY$=" " THEN =R$+"This is qu
ite boring."
  610 IF LEFT$(REPLY$,4)=" BYE" THEN BYE
=TRUE:=""
  620 Z%=0:FLAG=FALSE
  630 REPEAT Z%=Z%+1
  640   D%=INSTR(REPLY$,B$(Z%))
  650   IF D%<>0 THEN FLAG=TRUE
  660   UNTIL Z%=S% OR FLAG
  670 IF D%=0 THEN =R$+FN_NOREP(RND(13))
  680 R$=R$+C$(Z%)+" "
  690 IF RIGHT$(C$(Z%),1)<"A" THEN =R$
  700 H%=LEN(REPLY$)-(D%+LEN(B$(Z%)))
  710 IF H%>0 THEN REPLY$=RIGHT$(REPLY$,
H%):reply$=RIGHT$(reply$,H%)
  720 Z%=0:FLAG=FALSE
  730 REPEAT Z%=Z%+1
  740   D%=INSTR(REPLY$,F$(Z%))
  750   IF D%<>0 THEN FLAG=TRUE
  760   UNTIL Z%=10 OR FLAG
  770 IF D%=0 THEN =R$+reply$
  780 J$=LEFT$(reply$,(D%-1))+" "+G$(Z%)
  790 R$=R$+J$
  800 IF Z%>2 THEN L$=RIGHT$(reply$,(Z%-
2)):IF INSTR(TEMP$,L$)=0 THEN =R$+L$
  810 IF Z%>2 THEN =R$+RIGHT$(reply$,(Z%
-2))
  820 =R$
  830 DEF FN_NOREP(N%)
  840 ON N% GOTO 850,860,870,880,890,900
,910,920,930,940,950,960 ELSE 970
  850 ="What does that suggest to you?"
  860 ="I see..."
  870 ="I'm not sure that I understand y
ou fully."
  880 ="Can you elaborate on that?"
  890 ="That is quite interesting!"
  900 ="That's so...please continue..."
  910 ="I understand..."
  920 ="Well,well..do go on."
  930 ="Why are you saying that?"
  940 ="Please explain the background to
 that remark..."
  950 ="Could you say that again,in a di
fferent way?"
  960 ="Have you seen a Doctor about thi
s?"
  970 ="I think you're mad."
  980 DEF PROC_JUSTIFY(O$)
  990 LOCAL C%,L%,T%,P%,C$,T$
 1000 IF O$="" THEN PRINT:ENDPROC
 1010 FOR P%=1 TO LEN(O$)
 1020 T$=""
 1030 REPEAT C$=MID$(O$,P%,1)
 1040   T$=T$+C$
 1050   P%=P%+1
 1060   UNTIL (P%-1)>=LEN(O$) OR LEN(T$)
>39
 1070 P%=P%-1
 1080 IF P%>=LEN(O$) THEN 1150
 1090 REPEAT
 1100   P%=P%-1
 1110   T$=LEFT$(T$,LEN(T$)-1)
 1120   UNTIL RIGHT$(T$,1)=" " OR RIGHT$
(T$,1)="," OR RIGHT$(T$,1)="." OR LEN(T$
)=1
 1130 IF RIGHT$(T$,1)=" " THEN T$=LEFT$(
T$,LEN(T$)-1)
 1140 IF LEN(T$)=1 THEN T$=MID$(O$,P%,38
)+"-":P%=P%+37
 1150 FOR L%=1 TO LEN(T$)
 1160 C$=MID$(T$,L%,1)
 1170 IF C$="#" THEN VDU 7 ELSE PRINT C$
;
 1180 FOR T%=1 TO 1:NEXT
 1190 NEXT
 1200 PRINT
 1210 NEXT
 1220 ENDPROC
 1230 DEF PROC_QUIT
 1240 PROC_JUSTIFY("You're going then "+
name$+".Bye bye.")
 1250 PRINT''
 1260 *FX 202 32
 1270 ENDPROC
 1280 PRINT
 1290 IF ERR<>17 THEN REPORT:PRINT" at l
ine ";ERL ELSE PROC_JUSTIFY("Bye bye.")
 1300 PRINT''
 1310 END
 1320 DEF PROC_INIT
 1330 S%=58
 1340 DIM B$(S%),C$(S%),F$(10),G$(10)
 1350 RESTORE 1490
 1360 FOR A%=1 TO S%
 1370 READ B$(A%),C$(A%)
 1380 B$(A%)=" "+B$(A%)
 1390 NEXT
 1400 RESTORE 2000
 1410 FOR A%=1 TO 10
 1420 READ F$(A%),G$(A%)
 1430 F$(A%)=" "+F$(A%)
 1440 NEXT
 1450 ENDPROC
 1460  
 1470 REM KEYWORDS AND REPLIES
 1480  
 1490 DATA "COLOURS","I have lots of col
ours-[fs1]Red,[fs2]Green,[fs3]yellow,[fs
4]Blue,[fs5]Magenta,[fs6]Cyan[fs7]and Wh
ite."
 1500 DATA "COLOUR","Like colours in a r
ainbow?"
 1510 DATA "HELP","What makes you think 
I know any better?"
 1520 DATA "CAN YOU","Perhaps you would 
like to be able to"
 1530 DATA "OLD","Age is a thing that ne
ver bothers me so I don't know why it sh
ould you."
 1540 DATA "HELLO","Haven't we been thro
ugh this before?"
 1550 DATA "DO YOU","Yes,I"
 1560 DATA "CAN I","Perhaps you don't wa
nt to be able to"
 1570 DATA "YOU ARE","What makes you thi
nk I am"
 1580 DATA "YOU'RE","What is your reacti
on to me being"
 1590 DATA "I DON'T","Why don't you"
 1600 DATA "I FEEL","Tell me more about 
feeling"
 1610 DATA "HOW ARE","OK thanks."
 1620 DATA "HOW","Are you being personal
?"
 1630 DATA "SOUND","I can make sounds li
ke this#"
 1640 DATA "THANK","Its a pleasure."
 1650 DATA "FLASH","[fs8]Like tis[fs9]?"
 1660 DATA "WHY DON'T YOU","Why would yo
u want me to"
 1670 DATA "WHY CAN'T I","What makes you
 think you should be able to"
 1680 DATA "ARE YOU","Why are you intere
sted in whether or not I am"
 1690 DATA "I CAN'T","How do you know yo
u can't"
 1700 DATA "SEX","I fel that you should 
really discuss this with a human"
 1710 DATA "I AM","How long have you bee
n"
 1720 DATA "I'M","Why are you telling me
 you're"
 1730 DATA "I WANT","People who want don
't get."
 1740 DATA "I WOULD","Why would you"
 1750 DATA "WHAT","What do you think?"
 1760 DATA "WHO","How often do you think
 of such questions?"
 1770 DATA "WHERE","Why did you ask me t
hat?"
 1780 DATA "WHEN","What would your best 
friend say to that question?"
 1790 DATA "WHY","What is it that you re
ally want to know?"
 1800 DATA "PERHAPS","You're not very fi
rm on that!"
 1810 DATA "ALMOST","Accuracy is somethi
ng that bothers me alot.Please be more p
recise."
 1820 DATA "DRINK","Moderation in all th
ings should be the rule."
 1830 DATA "SORRY","Why are you apologiz
ing?"
 1840 DATA "DREAM","Why did you bring up
 the subject of dreams?"
 1850 DATA "I LIKE","It is good that you
 like"
 1860 DATA "MAYBE","Aren't you being a b
it tentative?"
 1870 DATA "NO","Why are you being negat
ive?"
 1880 DATA "LOVE","Don't talk about such
 soppy matters."
 1890 DATA "YOUR","Why are you concerned
 about my"
 1900 DATA "ALWAYS","Can you think of a 
specific example?"
 1910 DATA "THINK","Don't strain too muc
h."
 1920 DATA "SPELLING","Are you questioni
ng my spelling?"
 1930 DATA "YES","You seem quite certain
. Why is this so?"
 1940 DATA "FRIENDS","Why do you bring u
p the subject of friends?"
 1950 DATA "COMPUTER","Why do you mentio
n computers?"
 1960 DATA "AM I","You are"
 1970  
 1980 REM CONJUGATES
 1990  
 2000 DATA I,you
 2010 DATA ARE,am
 2020 DATA WERE,was
 2030 DATA YOU,me
 2040 DATA YOUR,my
 2050 DATA I'VE,you've
 2060 DATA I'M,you're
 2070 DATA ME,you
 2080 DATA AM I,you are
 2090 DATA AM,are


Animal


In this game the computer learns how to distinguish between different animals, gradually building up a formidable bank of knowledge.
   When you run it, the computer will first ask if you're thinking of an animal. It will then ask if the animal you're thinking of is a mammal. Based on your answers, the computer gradually learns what to ask in order to distinguish between various animals, building up a solid database as it does so. You can easily modify the program to identify such things as makes of cars or brands of computers. Just modify the final line (2190) of the program to suit the topic you want the computer to discuss.
   This program can be used to develop a very effective 'artificial intelligence' which could, for example, be used for somewhat primitive medical diagnosis. You can save a database so your BBC Micro can become more and more intelligent until it is almost as bright as you are. Full instructions are within the program.

   10 REM ANIMAL
   20  
   30 MODE 7
   40 PROC_INIT
   50 REPEAT
   60   PROC_NEWGAME
   70   IF quit THEN 120
   80   REPEAT
   90     PROC_ASK
  100     UNTIL LEFT$(RECORD$(CURRENT%),
2)<>"/Q"
  110   PROC_GUESS
  120   UNTIL quit
  130 PROC_OPTIONS
  140 IF NOT QUIT THEN 50
  150 PRINT'"[fs2]BYE"
  160 END
  170  
  180 DEF PROC_INIT
  190 D%=200
  200 DIM RECORD$(D%)
  210 READ TITLE$
  220 PROC_TITLE(TITLE$)
  230 FOR A%=0 TO 3
  240 READ RECORD$(A%)
  250 NEXT
  260 E%=A%
  270 PRINT''
  280 ON ERROR GOTO 130
  290 ENDPROC
  300 DEF PROC_NEWGAME
  310 PRINT'''''
  320 ASK$="[fs1]Are you thinking of a"
  330 IF INSTR("AEIOU",LEFT$(TITLE$,1))<
>0 THEN ASK$=ASK$+"n"
  340 ASK$=ASK$+" "+TITLE$+" ?"+CHR$(140
)
  350 PROC_DH(ASK$)
  360 PRINT''''TAB(1+LEN(ASK$),VPOS-7);
  370 quit=NOT FN_YN
  380 PRINT''
  390 N%=VAL(RECORD$(0)):CURRENT%=1
  400 ENDPROC
  410 DEF PROC_ASK
  420 Q$=RECORD$(CURRENT%):T$="[fs3]"
  430 FOR Z%=3 TO LEN(Q$)
  440 IF MID$(Q$,Z%,1)<>"/" THEN T$=T$+M
ID$(Q$,Z%,1) ELSE Z%=LEN(Q$)
  450 NEXT
  460 PROC_CL(T$+" ?")
  470 IF FN_YN THEN T$="/Y" ELSE T$="/N"
  480 X%=INSTR(Q$,T$)
  490 Y%=INSTR(MID$(Q$,X%-1),"/")
  500 CURRENT%=VAL(MID$(Q$,X%+2,Y%-X%-2)
)
  510 ENDPROC
  520 DEF PROC_GUESS
  530 AN$=RIGHT$(RECORD$(CURRENT%),LEN(R
ECORD$(CURRENT%))-2)
  540 PROC_CL("[fs3][fs0]Is it a[fs2]"+A
N$+"[fs3]? ")
  550 IF FN_YN THEN PROC_CL("[fs8][fs6][
fs0]How clever I am![fs0]"):ENDPROC
  560 PROC_CL("[fs6][fs0]What were you t
hinking of then ?[fs2][fs0]A ")
  570 REPEAT
  580   INPUT""A$
  590   A$=FN_UCASE(A$)
  600   IF LEN(A$)=0 THEN PROC_CL("[fs8]
[fs1]PLEASE TELL ME[fs0]")
  610   UNTIL LEN(A$)>0
  620 PROC_CL("[fs6][fs0]Please type in 
a question that would distinguish a[fs2]
"+AN$+"[fs6]from a[fs2]"+A$+"[fs6][fs0]?
")
  630 INPUT"[fs6]"QUEST$
  640 QUEST$=FN_CONV(QUEST$)
  650 IF LEN(QUEST$)=0 THEN PROC_CL("[fs
1]PLEASE TYPE IN A QUESTON:"):GOTO 630
  660 PROC_CL("[fs3][fs0]And the answer 
for a[fs2]"+A$+"[fs3]would be[fs0]?")
  670 IF FN_YN THEN B$="N":C$="Y" ELSE B
$="Y":C$="N"
  680 W%=VAL(RECORD$(0))
  690 RECORD$(0)=STR$(W%+2):RECORD$(W%)=
RECORD$(CURRENT%)
  700 RECORD$(W%+1)="/A"+A$
  710 RECORD$(CURRENT%)="/Q"+QUEST$+"/"+
C$+STR$(W%+1)+"/"+B$+STR$(W%)+"/"
  720 ENDPROC
  730 DEF FN_YN
  740 LOCAL KEY$
  750 *FX 15 1
  760 REPEAT KEY$=GET$
  770   UNTIL KEY$="Y" OR KEY$="y" OR KE
Y$="N" OR KEY$="N"
  780 IF KEY$="Y" OR KEY$="y" THEN PRINT
"Yes":=TRUE ELSE PRINT"No":=FALSE
  790 DEF FN_UCASE(S$)
  800 LOCAL C$,T$,L%
  810 T$=" "
  820 FOR L%=1 TO LEN(S$)
  830 C$=MID$(S$,L%,1)
  840 IF C$>="A" AND C$<="Z" THEN T$=T$+
C$
  850 IF C$>="0" AND C$<="9" THEN T$=T$+
C$
  860 IF C$>="a" AND C$<="z" THEN T$=T$+
CHR$(ASC(C$)-32)
  870 IF C$=" " AND RIGHT$(T$,1)<>" " TH
EN T$=T$+" "
  880 NEXT
  890 =MID$(T$,2)
  900 DEF FN_CONV(S$)
  910 LOCAL Q$,T$,C$,L%
  920 Q$=FN_UCASE(S$)
  930 T$=LEFT$(Q$,1)
  940 FOR L%=2 TO LEN(Q$)
  950 C$=MID$(Q$,L%,1)
  960 IF C$>="A" AND C$<="Z" THEN T$=T$+
CHR$(ASC(C$)+32) ELSE T$=T$+C$
  970 NEXT
  980 =T$
  990 DEF PROC_CL(S$)
 1000 LOCAL C$,L%,C%,F%
 1010 C%=135:F%=FALSE:PRINT"[fs9]";
 1020 FOR L%=1 TO LEN(S$)
 1030 C$=MID$(S$,L%,1)
 1040 IF C$="[fs0]" OR POS+INSTR(MID$(S$
,L%)," ")>39 THEN PRINT'CHR$(C%);CHR$(13
7+F%);
 1050 IF C$>"[fs0]" AND C$<"[fs8]" THEN 
C%=ASC(C$)
 1060 IF C$<>"[fs0]" THEN PRINT C$;
 1070 IF C$="[fs8]" THEN F%=TRUE
 1080 IF C$="[fs9]" THEN F%=FALSE
 1090 NEXT
 1100 ENDPROC
 1110 DEF PROC_DH(S$)
 1120 PRINT CHR$(141);S$
 1130 PRINT CHR$(141);S$
 1140 IF RIGHT$(S$,1)<>"[fs0]" THEN PRIN
T
 1150 ENDPROC
 1160 DEF PROC_OPTIONS
 1170 CLOSE #0
 1180 REPEAT
 1190   QUIT=FALSE
 1200   VDU 26,12,15
 1210   PRINT TAB(12,2);CHR$(141);"[fs3]
OPTIONS"
 1220   PRINT TAB(12,3);CHR$(141);"[fs3]
OPTIONS"'
 1230   PROC_DH("  [fs1]1) List Database
.")
 1240   PROC_DH("  [fs1]3)[fs2]Load Data
base.")
 1250   PROC_DH("  [fs1]5)[fs3]Save Data
base.")
 1260   PROC_DH("  [fs1]7)[fs4]Start Aga
in.")
 1270   PROC_DH("  [fs1]9)[fs6]Quit Pror
am.")
 1280   PRINT"[fs1]RETURN continues ques
tions."'
 1290   PROC_DH("[fs1]Your choice 1,3,5,
7,9 or RETURN ?[fs0]")
 1300   PRINT TAB(36,22);
 1310   REPEAT KEY$=GET$
 1320     UNTIL VAL(KEY$) MOD 2=1 OR ASC
(KEY$)=13
 1330   PRINT KEY$;CHR$(10);CHR$(8);KEY$
 1340   IF KEY$="1" THEN PROC_LIST
 1350   IF KEY$="3" THEN PROC_LOAD
 1360   IF KEY$="5" THEN PROC_SAVE
 1370   IF KEY$="7" THEN RUN
 1380   IF KEY$="9" QUIT=TRUE
 1390   UNTIL QUIT OR KEY$=CHR$(13)
 1400 IF KEY$=CHR$(13) THEN PROC_TITLE(T
ITLE$)
 1410 ENDPROC
 1420 DEF PROC_LIST
 1430 LOCAL L%
 1440 VDU 12,10,10,14
 1450 PROC_DH("[fs1]Contents of Database
")
 1460 PRINT
 1470 PROC_DH("[fs3]Questions.")
 1480 FOR L%=1 TO VAL(RECORD$(0))-1
 1490 IF LEFT$(RECORD$(L%),2)="/Q" THEN 
PRINT"[fs3]";MID$(RECORD$(L%),3,INSTR(MI
D$(RECORD$(L%),3),"/")-1)
 1500 NEXT
 1510 PRINT'
 1520 PROC_DH("[fs2]Answers.")
 1530 FOR L%=1 TO VAL(RECORD$(0))-1
 1540 IF LEFT$(RECORD$(L%),2)="/A" THEN 
PRINT"[fs2]";MID$(RECORD$(L%),3)
 1550 NEXT
 1560 PRINT
 1570 VDU 15
 1580 PROC_DH("[fs1]Press RETURN to cont
inue.[fs0]")
 1590 *FX 15 1
 1600 REPEAT UNTIL GET=13
 1610 VDU 15
 1620 ENDPROC
 1630 DEF PROC_LOAD
 1640 PROC_TITLE("LOAD")
 1650 PRINT''
 1660 PROC_DH("[fs1]Are you sure you wis
h to load?[fs0]")
 1670 IF NOT FN_YN THEN ENDPROC
 1680 INPUT''"[fs3]Filename for Database
 :[fs2]"filename$
 1690 filename$=LEFT$(filename$,10)
 1700 ch=OPENIN(filename$)
 1710 IF ch=0 THEN PRINT"[fs2]";filename
$;"[fs3]does not exist.":GOTO 1650
 1720 INPUT #ch,TITLE$
 1730 PROC_TITLE(TITLE$)
 1740 PROC_DH("[fs8][fs6]LOADING "+filen
ame$)
 1750 FOR A%=0 TO D%
 1760 RECORD$(A%)=""
 1770 NEXT
 1780 index=0
 1790 REPEAT
 1800   INPUT #ch,RECORD$(index)
 1810   index=index+1
 1820   UNTIL EOF #ch
 1830 CLOSE #ch
 1840 PROC_DH("[fs1]LOADED[fs0]")
 1850 PRINT
 1860 PROC_DH("[fs1]Press RETURN to cont
inue.[fs0]")
 1870 *FX 15 1
 1880 REPEAT UNTIL GET=13
 1890 ENDPROC
 1900 DEF PROC_SAVE
 1910 PROC_TITLE("SAVE")
 1920 PRINT''
 1930 PROC_DH("[fs1]Are you sure you wan
t to save ?")
 1940 IF NOT FN_YN THEN ENDPROC
 1950 INPUT''"[fs3]Filename for Database
 :[fs2]"filename$
 1960 filename$=LEFT$(filename$,10)
 1970 IF LEN(filename$)=0 THEN 1920
 1980 ch=OPENOUT(filename$)
 1990 PROC_DH("[fs6][fs8]SAVING "+filena
me$)
 2000 PRINT #ch,TITLE$
 2010 index=0
 2020 REPEAT
 2030   IF RECORD$(index)<>"" THEN PRINT
 #ch,RECORD$(index)
 2040   index=index+1
 2050   UNTIL RECORD$(index)=""
 2060 CLOSE #ch
 2070 PROC_DH("[fs1]SAVED")
 2080 PRINT
 2090 PROC_DH("[fs1]Press RETURN to cont
inue.[fs0]")
 2100 *FX 15 1
 2110 REPEAT UNTIL GET=13
 2120 ENDPROC
 2130 DEF PROC_TITLE(TITLE$)
 2140 VDU 26,12
 2150 PRINT TAB(18-(LEN(TITLE$) DIV 2),2
);CHR$(141);"[fs3]";TITLE$
 2160 PRINT TAB(18-(LEN(TITLE$) DIV 2),3
);CHR$(141);"[fs1]";TITLE$
 2170 VDU 28,0,24,39,4,12
 2180 ENDPROC
 2190 DATA "ANIMAL","4","/QIs it a Mamma
l/Y2/N3","/ALION","/AFISH"