OPTION GOSUB
DEFINT A-Z
DECLARE SUB Clrmain (col)
DECLARE SUB Mainscreen ()
DECLARE SUB Top ()
DECLARE SUB Bottom ()
DECLARE SUB Drawbox (x$)
DECLARE SUB Wcircle (wl, wc)
DECLARE FUNCTION Centre$ (text$)
DECLARE FUNCTION reporterror$ (errcode%)


'Language Learner with No Name - LLNN
'Version 2.4
'(c)1996 M.J.London


rem ON ERROR GOTO panic
rem RANDOMIZE TIMER
DIM word$(200, 4)
DIM qword$(200, 4)
DIM termsen(10)
DIM vocab$(1000, 3)
DIM quest$(500, 3)
DIM quest(10)
'PLAY "MBT230"
path$ = ""
vocab = 0
question = 0
bcol = 1
lcol = 14
ucol = 7
txtin = 0
s# = TIMER
FOR i# = 1 TO 10000: NEXT i#
st# = TIMER
speed# = 0
speed# = (st# - s#)
speed# = (1 / speed#) * 300
speed = INT(speed#)
ai = 0
file$ = ""
FOR a = 1 TO LEN(COMMAND$)
    IF MID$(COMMAND$, a, 1) = "/" AND MID$(COMMAND$, a + 1, 1) = "L" AND MID$(COMMAND$, a + 2, 1) = ":" THEN
        FOR x = a + 3 TO LEN(COMMAND$)
            IF MID$(COMMAND$, x, 1) = " " OR MID$(COMMAND$, x, 1) = "/" THEN GOTO fish
            file$ = file$ + MID$(COMMAND$, x, 1)
        NEXT x
    END IF
    IF MID$(COMMAND$, a, 1) = "/" AND MID$(COMMAND$, a + 1, 1) = "A" THEN
        ai = 1
    END IF
NEXT a
fish:
IF x > 0 THEN
    IF MID$(COMMAND$, x, 1) = "/" THEN
        IF MID$(COMMAND$, x + 1, 1) = "A" THEN ai = 1
    END IF
END IF
GOSUB setupscreen
IF ai = 0 THEN SCREENSET 1, 1 ELSE SCREENSET 2, 2
st = 1
COLOR ucol, bcol
Mainscreen
user$ = "#VER"
progst = 1
GOTO commands
st:
IF progst = 1 AND file$ <> "" THEN user$ = "#LOAD": GOTO commands
progst = 0
file$ = ""
IF st = 1 THEN
COLOR lcol
PRINT " LLNN : Hi There!, type #QUIT to EXIT or #? for HELP"
st = 0
END IF
COLOR ucol, bcol
IF txtin = 1 THEN
IF EOF(1) THEN CLOSE : txtin = 0: Clrmain (bcol)
END IF
IF txtin = 0 THEN
    IF CSRLIN > 22 THEN user$ = "#CLS": GOTO commands
    COLOR ucol, bcol
    LINE INPUT " USER: "; user$
ELSE
    INPUT #1, user$
    CALL Wcircle(24, 45)
END IF
isquest = 0
IF user$ = "" THEN GOTO reply
user$ = user$ + " "
user$ = UCASE$(user$)
IF txtin = 0 AND LEFT$(user$, 1) = "#" THEN GOTO commands

FOR x = 1 TO 10
quest(x) = 0
NEXT x
x = 0
termsen(0) = 0
sentences = 0
DO UNTIL x >= LEN(user$)
sentences = sentences + 1: IF sentences > 10 THEN sentences = 10: GOTO done
termsen(sentences) = 0
FOR x = termsen(sentences) + 1 TO LEN(user$)
a$ = MID$(user$, x, 1)
IF a$ = "." OR a$ = "!" THEN MID$(user$, x, 1) = " ": termsen(sentences) = x
IF a$ = "?" THEN MID$(user$, x, 1) = " ": quest(sentences) = 1: termsen(sentences) = x: isquest = 1
IF a$ = "," THEN MID$(user$, x, 1) = " "
IF termsen(sentences) > 0 THEN GOTO nxt
NEXT x
nxt:
IF x >= LEN(user$) THEN termsen(sentences) = LEN(user$)
LOOP
done:

FOR x = 1 TO 200
qword$(x, 4) = "0"
word$(x, 4) = "0"
NEXT x
word$(1, 0) = ""
word$(1, 1) = ""
word$(1, 2) = ""
words = 1
qword$(1, 0) = ""
qword$(1, 1) = ""
qword$(1, 2) = ""
qwords = 1
x = 0
qs = 0
FOR z = 1 TO sentences
flag2 = 1: sst = 1
IF quest(z) = 1 THEN
    qs = 1
    FOR x = termsen(z - 1) TO termsen(z)
    IF x = 0 THEN x = 1
    a$ = MID$(user$, x, 1)
    IF a$ <> " " THEN
        qword$(qwords, 0) = qword$(qwords, 0) + a$:  flag = 0
        IF x = termsen(z) - 1 THEN qword$(qwords, 3) = "1" ELSE qword$(qwords, 3) = "0"
        IF flag2 = 1 THEN qword$(qwords, 1) = "1" ELSE qword$(qwords, 1) = "0"
        sst = 0
    END IF
    IF x = termsen(z) THEN qword$(qwords, 4) = "1"
    IF a$ = " " THEN
        w = 0
        FOR p = 1 TO questions
        IF qword$(qwords, 0) = quest$(p, 0) THEN w = p: GOTO ntbit
        NEXT p
ntbit:
        IF w <> 0 THEN qword$(qwords, 2) = LTRIM$(STR$(w))
        IF w = 0 AND questions < 501 THEN
            questions = questions + 1
            FOR p = 0 TO 3
                quest$(questions, p) = qword$(qwords, p)
            NEXT p
            qword$(qwords, 2) = LTRIM$(STR$(questions))
        END IF
    END IF
    IF a$ = " " AND flag = 0 AND x < LEN(user$) - 1 AND MID$(user$, x + 1, 1) <> " " THEN
        qwords = qwords + 1
        flag = 1
        qword$(qwords, 0) = ""
        qword$(qwords, 1) = ""
        qword$(qwords, 2) = ""
        qword$(qwords, 3) = ""
        IF sst = 1 THEN flag2 = 1 ELSE flag2 = 0
    END IF
    NEXT x
ELSE
    FOR x = termsen(z - 1) TO termsen(z)
    IF x = 0 THEN x = 1
    a$ = MID$(user$, x, 1)
    IF a$ <> " " THEN
        word$(words, 0) = word$(words, 0) + a$:  flag = 0
        IF x = termsen(z) - 1 THEN word$(words, 3) = "1" ELSE word$(words, 3) = "0"
        IF flag2 = 1 THEN word$(words, 1) = "1" ELSE word$(words, 1) = "0"
        sst = 0
    END IF
    IF a$ = " " THEN
        w = 0
        FOR p = 1 TO vocab
        IF word$(words, 0) = vocab$(p, 0) THEN w = p: GOTO nxtbit
        NEXT p
nxtbit:
        IF w <> 0 THEN word$(words, 2) = LTRIM$(STR$(w))
        IF w = 0 AND vocab < 1001 THEN
            vocab = vocab + 1
            FOR p = 0 TO 3
                vocab$(vocab, p) = word$(words, p)
            NEXT p
            word$(words, 2) = LTRIM$(STR$(vocab))
        END IF
    END IF
    IF x = termsen(z) THEN word$(words, 4) = "1"
    IF a$ = " " AND flag = 0 AND x < LEN(user$) - 1 AND MID$(user$, x + 1, 1) <> " " THEN
        words = words + 1
        flag = 1
        word$(words, 0) = ""
        word$(words, 1) = ""
        word$(words, 2) = ""
        word$(words, 3) = ""
        IF sst = 1 THEN flag2 = 1 ELSE flag2 = 0
    END IF
    NEXT x
END IF
NEXT z

FOR z = 1 TO words
FOR x = 1 TO vocab
IF word$(z, 0) = vocab$(x, 0) THEN
    IF vocab$(x, 1) = "0" THEN vocab$(x, 1) = word$(z, 1)
    IF vocab$(x, 3) = "0" THEN vocab$(x, 3) = word$(z, 3)
END IF
NEXT x

IF word$(z, 2) = "" AND word$(z, 0) <> "" THEN
    vocab = vocab + 1
    FOR p = 0 TO 3
    vocab$(vocab, p) = word$(z, p)
    NEXT p
    word$(z, 2) = LTRIM$(STR$(vocab))
END IF
NEXT z


FOR z = 1 TO qwords
FOR x = 1 TO questions
IF qword$(z, 0) = quest$(x, 0) THEN
    IF quest$(x, 1) = "0" THEN quest$(x, 1) = qword$(z, 1)
    IF quest$(x, 3) = "0" THEN quest$(x, 3) = qword$(z, 3)
END IF
NEXT x

IF qword$(z, 2) = "" AND qword$(z, 0) <> "" THEN
    questions = questions + 1
    FOR p = 0 TO 3
    quest$(questions, p) = qword$(z, p)
    NEXT p
    qword$(z, 2) = LTRIM$(STR$(questions))
END IF
NEXT z

FOR z = 1 TO words - 1
    w = VAL(word$(z, 2))
    link$ = ""
    IF VAL(word$(z + 1, 2)) > vocab THEN GOTO nde
    FOR x = 1 TO LEN(vocab$(w, 2))
        IF word$(z, 4) = "1" THEN GOTO nde
        IF MID$(vocab$(w, 2), x, 1) = "|" THEN
            IF link$ = word$(z + 1, 2) THEN GOTO nde
            link$ = ""
        ELSE
            link$ = link$ + MID$(vocab$(w, 2), x, 1)
        END IF
    NEXT x
    IF RIGHT$(vocab$(w, 2), 1) <> "|" AND LEN(vocab$(w, 2)) > 0 THEN vocab$(w, 2) = vocab$(w, 2) + "|"
    IF word$(z, 4) = "0" THEN vocab$(w, 2) = vocab$(w, 2) + word$(z + 1, 2) + "|"
'    vocab$(w, 2) = vocab$(w, 2) + word$(z + 1, 2) + "|"
nde:
NEXT z

FOR z = 1 TO qwords - 1
    w = VAL(qword$(z, 2))
    link$ = ""
    IF VAL(qword$(z + 1, 2)) > questions THEN GOTO nd
    FOR x = 1 TO LEN(quest$(w, 2))
        IF qword$(z, 4) = "1" THEN GOTO nd
        IF MID$(quest$(w, 2), x, 1) = "|" THEN
            IF link$ = qword$(z + 1, 2) THEN GOTO nd
            link$ = ""
        ELSE
            link$ = link$ + MID$(quest$(w, 2), x, 1)
        END IF
    NEXT x
    IF RIGHT$(quest$(w, 2), 1) <> "|" AND LEN(quest$(w, 2)) > 0 THEN quest$(w, 2) = quest$(w, 2) + "|"
    IF qword$(z, 4) = "0" THEN quest$(w, 2) = quest$(w, 2) + qword$(z + 1, 2) + "|"
nd:
NEXT z

IF txtin = 1 THEN GOTO st

reply:
IF vocab = 0 AND questions = 0 THEN llnn$ = "I have no words in my vocabulary yet!": GOTO prn
IF txtin = 1 THEN GOTO st
IF questions > 0 AND vocab > 0 THEN askq = INT(RND * 3) + 1
IF vocab <= 1 THEN askq = 1
IF questions = 0 THEN askq = 2

llnn$ = ""
'IF askq = 1 AND questions > 0 THEN
IF askq = 1 THEN
'Ask a Question
x = 0
DO UNTIL quest$(x, 1) = "1"
x = INT(RND * questions) + 1
LOOP
q:
llnn$ = llnn$ + quest$(x, 0)
IF quest$(x, 3) = "1" AND INT(RND * 2) = 1 OR quest$(x, 2) = "0" OR quest$(x, 2) = "" THEN llnn$ = llnn$ + "?": GOTO prn
C = 0
FOR l = 1 TO LEN(quest$(x, 2))
IF MID$(quest$(x, 2), l, 1) = "|" THEN C = C + 1
NEXT l
w = INT(RND * C)
t$ = ""
C = 0
FOR l = 1 TO LEN(quest$(x, 2))
IF MID$(quest$(x, 2), l, 1) = "|" THEN C = C + 1: GOTO fred
IF C = w THEN t$ = t$ + MID$(quest$(x, 2), l, 1)
fred:
NEXT l
llnn$ = llnn$ + " "
x = VAL(t$)
GOTO q

ELSEIF askq <> 1 THEN
'Make a statment
x = 0
DO UNTIL vocab$(x, 1) = "1"
x = INT(RND * vocab + 1)
LOOP
qw:
llnn$ = llnn$ + vocab$(x, 0)
IF vocab$(x, 3) = "1" AND INT(RND * 2) = 1 OR vocab$(x, 2) = "" THEN llnn$ = llnn$ + ".": GOTO prn
C = 0
FOR l = 1 TO LEN(vocab$(x, 2))
IF MID$(vocab$(x, 2), l, 1) = "|" THEN C = C + 1
NEXT l
w = INT(RND * C)
t$ = ""
C = 0
FOR l = 1 TO LEN(vocab$(x, 2))
IF MID$(vocab$(x, 2), l, 1) = "|" THEN C = C + 1: GOTO fredy
IF C = w THEN t$ = t$ + MID$(vocab$(x, 2), l, 1)
fredy:
NEXT l
llnn$ = llnn$ + " "
x = VAL(t$)
GOTO qw

END IF
prn:
COLOR lcol, bcol
PRINT " LLNN: "; llnn$
GOTO st:

commands:
cl = CSRLIN - 1
IF progst = 1 OR cl < 4 THEN cl = CSRLIN
IF LEFT$(user$, 7) = "#COLOUR" THEN
    IF CSRLIN > 15 THEN Clrmain (bcol)
    noe = 1
    tl = lcol
    tu = ucol
    tb = bcol
    PRINT "Current LLNN Colour = "; lcol
    PRINT "Current User Colour = "; ucol
    PRINT
    INPUT "New LLNN Colour (Enter to leave unchanged) "; lcol
    INPUT "New USER Colour (Enter to leave unchanged) "; ucol
    INPUT "New BACK Colour (Enter to leave unchanged) "; bcol
    IF lcol = 1 THEN lcol = 14
    IF ucol = 1 THEN ucol = 7
    IF lcol < 0 THEN lcol = 0
    IF lcol > 15 THEN lcol = 15
    IF ucol < 0 THEN ucol = 0
    IF bcol > 7 THEN bcol = 7
    IF bcol < 0 THEN bcol = 0
    IF ucol > 15 THEN ucol = 15
    IF lcol = 0 THEN lcol = tl
    IF ucol = 0 THEN ucol = tu
    IF bcol = 0 THEN bcol = tb
    IF ucol = bcol THEN ucol = 15
    IF lcol = bcol THEN lcol = 14
    IF bcol <> tb THEN
        COLOR , bcol
        CLS 0
        Top
        COLOR 15
        CALL Drawbox("Language Learner with No Name - LLNN")
        Bottom
        CALL Drawbox("(c) 1996 M.J.London. THIS VERSION IS SHAREWARE!!!")
        COLOR ucol, bcol
        Mainscreen
        cl = 4
        noe = 0
    END IF
END IF
IF LEFT$(user$, 5) = "#COPY" THEN
    ON ERROR GOTO fileerr
    OPEN "COMMENTS.DAT" FOR APPEND AS #1
    PRINT #1, llnn$
    CLOSE #1
    ON ERROR GOTO panic
END IF
IF LEFT$(user$, 5) = "#TEXT" THEN
    IF CSRLIN > 17 THEN Clrmain (bcol)
    noe = 1
    PRINT
    LINE INPUT "Text File to Load : "; tfile$
    ON ERROR GOTO fileerr
    OPEN tfile$ FOR INPUT AS #1
    txtin = 1
    Bottom
    COLOR 15, bcol
    CLS
    Drawbox ("Loading...")
    COLOR ucol, bcol
    ON ERROR GOTO panic
END IF
IF LEFT$(user$, 8) = "#CORRECT" THEN
    IF CSRLIN > 15 THEN Clrmain (bcol)
    noe = 1
    PRINT
    LINE INPUT "Enter Incorrect word : "; iword$
    iword$ = UCASE$(iword$)
    w = 0
    FOR x = 1 TO vocab
        IF vocab$(x, 0) = iword$ THEN w = x: GOTO cor
    NEXT x
    q = 0
    FOR x = 1 TO questions
        IF quest$(x, 0) = iword$ THEN w = x: q = 1: GOTO cor
    NEXT x
cor:
    IF w = 0 THEN PRINT "Word not found!": PRINT : GOTO st
    LINE INPUT "Enter Correct  Word  : "; w$
    w$ = UCASE$(w$)
    IF q = 1 THEN quest$(w, 0) = w$ ELSE vocab$(w, 0) = w$
    PRINT "Done!"
    PRINT
END IF
IF LEFT$(user$, 2) = "##" THEN
    IF CSRLIN > 16 THEN Clrmain (bcol)
    noe = 1
    COLOR 15, bcol
    PRINT
    PRINT Centre("Words          : " + LTRIM$(STR$(vocab)))
    PRINT Centre("Question Words : " + LTRIM$(STR$(questions)))
    PRINT
    COLOR ucol, bcol
END IF
IF LEFT$(user$, 5) = "#LOAD" THEN
    ON ERROR GOTO fileerr
    noe = 1
    Clrmain (bcol)
    IF progst = 0 THEN file$ = ""
    COLOR 15, bcol
    PRINT Centre("Load File")
    IF progst <> 1 THEN
        LINE INPUT "Filename : "; file$
    ELSE
        PRINT "Filename :"; file$
    END IF
    file$ = UCASE$(file$)
    FOR x = LEN(file$) - 3 TO LEN(file$)
        IF MID$(file$, x, 1) = "." THEN GOTO load
    NEXT x
    file$ = file$ + ".LL"
load:
    OPEN file$ FOR INPUT AS #1
    Bottom
    COLOR 15, bcol
    CLS
    Drawbox ("Loading...")
    COLOR ucol, bcol
    INPUT #1, vocab, questions
    CALL Wcircle(-1, -1)
    FOR x = 1 TO vocab
        INPUT #1, vocab$(x, 0), vocab$(x, 1), vocab$(x, 2), vocab$(x, 3)
        CALL Wcircle(24, 45)
        FOR pa = 1 TO speed: NEXT pa
    NEXT x
    FOR x = 1 TO questions
        INPUT #1, quest$(x, 0), quest$(x, 1), quest$(x, 2), quest$(x, 3)
        CALL Wcircle(24, 45)
        FOR pa = 1 TO speed: NEXT pa
    NEXT x
    CALL Wcircle(-1, -1)
    CLOSE
    Clrmain (bcol)
    ON ERROR GOTO panic
    progst = 0: file$ = ""
END IF
IF LEFT$(user$, 5) = "#SAVE" THEN
    ON ERROR GOTO fileerr
    noe = 1
    Clrmain (bcol)
    file$ = ""
    COLOR 15, bcol
    PRINT Centre("Save File")
    LINE INPUT "Filename : "; file$
    file$ = UCASE$(file$)
    FOR x = LEN(file$) - 3 TO LEN(file$)
        IF MID$(file$, x, 1) = "." THEN GOTO save
    NEXT x
    file$ = file$ + ".LL"
save:
    Bottom
    COLOR 15, bcol
    CLS
    Drawbox ("Saveing...")
    COLOR ucol, bcol
    OPEN file$ FOR OUTPUT AS #1
    Bottom
    COLOR 15, bcol
    Drawbox ("Saving...")
    COLOR ucol, bcol
    WRITE #1, vocab, questions
    CALL Wcircle(-1, -1)
    FOR x = 1 TO vocab
        WRITE #1, vocab$(x, 0), vocab$(x, 1), vocab$(x, 2), vocab$(x, 3)
        CALL Wcircle(24, 45)
        FOR pa = 1 TO speed: NEXT pa
    NEXT x
    FOR x = 1 TO questions
        WRITE #1, quest$(x, 0), quest$(x, 1), quest$(x, 2), quest$(x, 3)
        CALL Wcircle(24, 45)
        FOR pa = 1 TO speed: NEXT pa
    NEXT x
    WRITE #1,
    PRINT #1, TIME$, DATE$
    CLOSE
    CALL Wcircle(-1, -1)
    Clrmain (bcol)
    ON ERROR GOTO panic
END IF
IF LEFT$(user$, 6) = "#ERROR" THEN ERROR VAL(MID$(user$, 8, 2))
IF LEFT$(user$, 8) = "#SCREENS" THEN
    IF ai = 1 THEN COLOR 15: PRINT Centre("Not Available!"): COLOR ucol: GOTO st:
    FOR x = 0 TO 3
	SCREENSET ,x
        SLEEP
        a$ = INKEY$
    NEXT x
    SCREENSET 1, 1
    COLOR ucol, bcol
END IF
IF LEFT$(user$, 5) = "#QUIT" THEN
    VIEW PRINT
    IF ai = 0 THEN
        SCREENSET , 0
    ELSE
        SCREENSET 2, 2
        COLOR , 0
        CLS 0
        COLOR , bcol
        VIEW PRINT 1 TO 15
        CLS
        COLOR 15
        Drawbox ("This Program is Shareware!")
        PRINT
        PRINT "Please Register this program!"
        COLOR 12
        PRINT "Please send œ5 and a blank disk to:"
        COLOR 15
        PRINT "                             M.J.London,"
        PRINT "                             49 Barley Road"
        PRINT "                              Thelwall"
        PRINT "                               Warrington"
        PRINT "                                Cheshire"
        PRINT "                                 WA4 2EZ"
        PRINT
        COLOR 10
        PRINT "Please send any comments or bug reports to the above address"
        COLOR 14
        PRINT Centre("To Register, please print and fill in REGISTER.DOC");
        VIEW PRINT 14 TO 25
        COLOR , 0
        CLS
        COLOR 14, 0
        PRINT
        PRINT "Shareware Countdown...";
        FOR a = 0 TO 5
            LOCATE 15, 23
            PRINT 5 - a
            x& = INT(TIMER)
            DO UNTIL INT(TIMER) <> x&
            LOOP
        NEXT a
        BEEP
    END IF
    COLOR 7, 0
    END
END IF
IF LEFT$(user$, 4) = "#VER" THEN
    IF ai = 0 THEN
        SCREENSET , 2
    ELSE
        SCREENSET 3, 3
        COLOR 15, bcol
        CLS
        CALL Drawbox("Language Learner with No Name - LLNN")
        PRINT
        COLOR 14
        CALL Drawbox("Version 2.4")
        COLOR 10
        PRINT
        PRINT
        PRINT Centre("Written in 1996 by M.J.London")
        PRINT
        COLOR 7
        PRINT Centre("Original idea from the Non-Inteligent AMOS Language Learner - NIALL")
        PRINT Centre("by Matthew Peck on the AMIGA")
        PRINT
        COLOR 13
        PRINT Centre("This version features compatibility with S.C.Kingston's 'AI' program")
        LOCATE 20, 1
        COLOR 12
        PRINT Centre("Press any key...")
        COLOR ucol, bcol
    END IF
    SLEEP
    a$ = INKEY$
    IF ai = 0 THEN SCREENSET , 1 ELSE SCREENSET 2, 2
'    Clrmain (bcol)
    COLOR ucol, bcol
END IF
IF LEFT$(user$, 4) = "#NEW" THEN
    noe = 1
    Clrmain (bcol)
    COLOR 15
    PRINT Centre("All Data Has Been Erased")
    ERASE vocab$
    ERASE quest$
    vocab = 0
    questions = 0
    COLOR ucol, bcol
END IF
IF LEFT$(user$, 4) = "#CLS" THEN
    CLS
    Top
    COLOR 15
    CALL Drawbox("Language Learner with No Name - LLNN")
    Bottom
    CALL Drawbox("(c) 1996 M.J.London. THIS VERSION IS SHAREWARE!!!")
    COLOR ucol, bcol
    Mainscreen
    cl = 4
END IF
IF LEFT$(user$, 2) = "#?" THEN
    IF ai = 0 THEN
        SCREENSET , 3
    ELSE
        SCREENSET 3, 3
        COLOR ucol, bcol
        CLS
        COLOR 15
        CALL Drawbox("L L N N   H e l p")
        PRINT
        PRINT
        COLOR 11
        PRINT Centre("#?..........This Screen!             ")
        PRINT Centre("##..........List Number of Words     ")
        PRINT Centre("#LIST.......List Words               ")
        PRINT Centre("#VER........Version Number           ")
        PRINT Centre("#CLS........Clear the Screen         ")
        PRINT Centre("#LOAD.......Load a File              ")
        PRINT Centre("#SAVE.......Save a File              ")
        PRINT Centre("#CORRECT....Correct a word           ")
        PRINT Centre("#TEXT.......Import an ASCII Text File")
        PRINT Centre("#COPY.......Save the last response   ")
        PRINT Centre("#COLOUR.....Change colours           ")
        PRINT Centre("#NEW........Start again              ")
        COLOR 12
        PRINT
        PRINT
        PRINT Centre("#QUIT.......QUIT!                    ")
        PRINT
        PRINT
        LOCATE 23, 1
        COLOR 14
        PRINT Centre("Press any key...")
    END IF
    DO UNTIL INKEY$ <> "": LOOP
    IF ai = 0 THEN SCREENSET , 1 ELSE SCREENSET 2, 2
    COLOR ucol, bcol
END IF
IF LEFT$(user$, 5) = "#LIST" THEN
    noe = 1
    Clrmain (bcol)
    COLOR lcol, bcol
    PRINT " #   "; "Word", "Start"; " "; "End"; " "; "Links"
    PRINT " "; STRING$(78, "Í")
    COLOR 15
    FOR x = 1 TO vocab
        PRINT x; ") "; vocab$(x, 0), vocab$(x, 1); " "; vocab$(x, 3); " "; vocab$(x, 2)
        IF CSRLIN >= 19 THEN PRINT "Press any key...": SLEEP: a$ = INKEY$: Clrmain (1): COLOR lcol, bcol: PRINT " #  "; "Word", "S"; " "; "E"; " "; "Links": PRINT " "; STRING$(78, "Í"): COLOR 15
    NEXT x
    FOR x = 1 TO questions
        PRINT x; ") "; quest$(x, 0), quest$(x, 1); " "; quest$(x, 3); " "; quest$(x, 2)
        IF CSRLIN >= 19 THEN PRINT "Press any key...": SLEEP: a$ = INKEY$: Clrmain (1): COLOR lcol, bcol: PRINT " #  "; "Word", "S"; " "; "E"; " "; "Links": PRINT " "; STRING$(78, "Í"): COLOR 15
    NEXT x
    COLOR ucol, bcol
END IF
IF noe = 1 THEN noe = 0: GOTO st
LOCATE cl, 1
PRINT "                                                 "
LOCATE cl, 1
GOTO st:


panic:
'Error Handler
Mainscreen
txtin = 0
CLS
Bottom
CLS
COLOR 12
Drawbox reporterror$(ERR)
'PLAY "O3L8GA>L4C<L8A>L4CC"
SLEEP
a$ = INKEY$
COLOR 15, bcol
CLS
CALL Drawbox("(c) 1996 M.J.London. THIS VERSION IS SHAREWARE!")
COLOR ucol, bcol
Mainscreen
GOTO st:

setupscreen:
SCREEN 17,,4
FOR a = 0 TO 3
    SCREENSET a,1
    COLOR ,bcol
    VIEW PRINT
    CLS
    COLOR 15
    MainScreen
NEXT a
IF ai = 0 THEN
    SCREENSET 0, 1
    COLOR , 0
    CLS
    COLOR , bcol
    VIEW PRINT 1 TO 15
    CLS
    COLOR 15
    Drawbox ("This Program is Shareware!")
    PRINT
    PRINT "Please Register this program!"
    COLOR 12
    PRINT "Please send œ5 and a blank disk to:"
    COLOR 15
    PRINT "                             M.J.London,"
    PRINT "                             49 Barley Road"
    PRINT "                              Thelwall"
    PRINT "                               Warrington"
    PRINT "                                Cheshire"
    PRINT "                                 WA4 2EZ"
    PRINT
    COLOR 10
    PRINT "Please send any comments or bug reports to the above address"
    COLOR 14
    PRINT Centre("To Register, please print and fill in REGISTER.DOC");
    VIEW PRINT 14 TO 25
    COLOR , 0
    CLS
    COLOR 7, 0
END IF
IF ai = 0 THEN SCREENSET 1, 1 ELSE SCREENSET 2, 2
COLOR , bcol
CLS
Top
COLOR 15
CALL Drawbox("Language Learner with No Name - LLNN")
Bottom
CALL Drawbox("(c) 1996 M.J.London. THIS VERSION IS SHAREWARE!!!")
MainScreen
COLOR 7
IF ai = 0 THEN
    SCREENSET 2, 1
    COLOR 15, bcol
    CLS
    CALL Drawbox("Language Learner with No Name - LLNN")
    PRINT
    COLOR 14
    CALL Drawbox("Version 2.4")
    COLOR 10
    PRINT
    PRINT
    PRINT Centre("Written in 1996 by M.J.London")
    PRINT
    COLOR 7
    PRINT Centre("Original idea from the Non-Inteligent AMOS Language Learner - NIALL")
    PRINT Centre("by Matthew Peck on the AMIGA")
    PRINT
    COLOR 13
    PRINT Centre("This version features compatibility with S.C.Kingston's 'AI' program")
    LOCATE 20, 1
    COLOR 12
    PRINT Centre("Press any key...")
    COLOR ucol, bcol

    SCREENSET 3, 1
    COLOR ucol, bcol
    CLS
    COLOR 15
    CALL Drawbox("L L N N   H e l p")
    PRINT
    PRINT
    COLOR 11
    PRINT Centre("#?..........This Screen!             ")
    PRINT Centre("##..........List Number of Words     ")
    PRINT Centre("#LIST.......List Words               ")
    PRINT Centre("#VER........Version Number           ")
    PRINT Centre("#CLS........Clear the Screen         ")
    PRINT Centre("#LOAD.......Load a File              ")
    PRINT Centre("#SAVE.......Save a File              ")
    PRINT Centre("#CORRECT....Correct a word           ")
    PRINT Centre("#TEXT.......Import an ASCII Text File")
    PRINT Centre("#COPY.......Save the last response   ")
    PRINT Centre("#COLOUR.....Change colours           ")
    PRINT Centre("#NEW........Start Again              ")
    COLOR 12
    PRINT
    PRINT
    PRINT Centre("#QUIT.......QUIT!                    ")
    PRINT
    PRINT
    LOCATE 23, 1
    COLOR 14
    PRINT Centre("Press any key...")
END IF
COLOR ucol, bcol
RETURN

fileerr:
'File Error Handler
'Only in Load and Save Commands
txtin = 0
CLOSE
Mainscreen
Clrmain (bcol)
COLOR 12
IF ERR = 52 OR ERR = 53 THEN
    e$ = reporterror$(ERR) + " : " + file$
ELSEIF ERR = 58 THEN
    PRINT "File Already Exists!"
    PRINT "Overwrite? (Y/N) ";
    SLEEP
    a$ = UCASE$(INKEY$)
    IF a$ <> "Y" THEN a$ = "N"
    PRINT a$
    IF a$ = "N" THEN GOTO st:
    KILL (file$)
    RESUME
ELSE
    e$ = reporterror$(ERR)
END IF
Bottom
COLOR 12, bcol
CLS
Drawbox e$
'PLAY "O3L8GA>L4C<L8A>L4CC"
SLEEP
a$ = INKEY$
COLOR 15, bcol
CLS
CALL Drawbox("Written in 1996 by M.London, Original Program called NIALL by M.Peck")
COLOR ucol, bcol
Mainscreen
GOTO st:

DEFSNG A-Z
SUB Bottom
VIEW PRINT 23 TO 25
END SUB

FUNCTION Centre$ (text$) STATIC
t = LEN(text$)
t = t / 2
t = 39 - t
t$ = STRING$(t, " ") + text$
Centre$ = t$
END FUNCTION

DEFINT A-Z
SUB Clrmain (col)
Mainscreen
COLOR , col
CLS
Bottom
COLOR 15, col
CALL Drawbox("(c) 1996 M.J.London. THIS VERSION IS SHAREWARE!!!")
Mainscreen
FOR pause = 1 TO 1000: NEXT pause
END SUB

DEFSNG A-Z
SUB Drawbox (x$) STATIC
bs = CSRLIN
LOCATE bs, 1
PRINT chr$(201); STRING$(78, chr$(205)); CHR$(187);
LOCATE bs + 1, 1
PRINT CHR$(186);
LOCATE bs + 1, 2
PRINT Centre$(x$);
LOCATE bs + 1, 80
PRINT CHR$(186);
PRINT CHR$(200); STRING$(78, CHR$(205)); CHR$(188);
END SUB

DEFINT A-Z
FUNCTION reporterror$ (errcode) STATIC
   SELECT CASE errcode
      CASE 1: st$ = "NEXT without FOR"
      CASE 2: st$ = "Syntax error"
      CASE 3: st$ = "RETURN without GOSUB"
      CASE 4: st$ = "Out of DATA"
      CASE 5: st$ = "Illegal function call"
      CASE 6: st$ = "Overflow"
      CASE 7: st$ = "Out of memory"
      CASE 8: st$ = "Label not defined"
      CASE 9: st$ = "Subscript out of range"
      CASE 10: st$ = "Duplicate definition"
      CASE 11: st$ = "Division by zero"
      CASE 12: st$ = "Illegal in direct mode"
      CASE 13: st$ = "Type mismatch"
      CASE 14: st$ = "Out of string space"
      CASE 16: st$ = "String formula too complex"
      CASE 17: st$ = "Cannot continue"
      CASE 18: st$ = "Function not defined"
      CASE 19: st$ = "No RESUME"
      CASE 20: st$ = "RESUME without error"
      CASE 24: st$ = "Device timeout"
      CASE 25: st$ = "Device fault"
      CASE 26: st$ = "FOR without NEXT"
      CASE 27: st$ = "Out of paper"
      CASE 29: st$ = "WHILE without WEND"
      CASE 30: st$ = "WEND without WHILE"
      CASE 33: st$ = "Duplicate label"
      CASE 35: st$ = "Subprogram not defined"
      CASE 37: st$ = "Argument-count mismatch"
      CASE 38: st$ = "Array not defined"
      CASE 40: st$ = "Variable required"
      CASE 50: st$ = "FIELD overflow"
      CASE 51: st$ = "Internal error"
      CASE 52: st$ = "Bad file name or number"
      CASE 53: st$ = "File not found"
      CASE 54: st$ = "Bad file mode"
      CASE 55: st$ = "File already open"
      CASE 56: st$ = "FIELD statement active"
      CASE 57: st$ = "Device I/O error"
      CASE 58: st$ = "File already exists"
      CASE 59: st$ = "Bad record length"
      CASE 61: st$ = "Disk full"
      CASE 62: st$ = "Input past end of file"
      CASE 63: st$ = "Bad record number"
      CASE 64: st$ = "Bad file name"
      CASE 67: st$ = "Too many files"
      CASE 68: st$ = "Device unavailable"
      CASE 69: st$ = "Communication-buffer overflow"
      CASE 70: st$ = "Permission denied"
      CASE 71: st$ = "Disk not ready"
      CASE 72: st$ = "Disk-media error"
      CASE 73: st$ = "Feature unavailable"
      CASE 74: st$ = "Rename across disks"
      CASE 75: st$ = "Path/File access error"
      CASE 76: st$ = "Path not found"
      CASE ELSE: st$ = "Unprintable error"
   END SELECT
   reporterror$ = st$
END FUNCTION

DEFSNG A-Z
SUB Mainscreen
VIEW PRINT 4 TO 22
END SUB

SUB Top
VIEW PRINT 1 TO 4
END SUB

DEFINT A-Z
SUB Wcircle (wl, wc) STATIC
IF wl < 0 THEN wl = 0: dc = 0: GOTO ndw
IF wc < 0 THEN wc = 0: dc = 0: GOTO ndw
IF dc = 1 THEN wl = tl: wc = tl
IF wl = 0 AND dc = 0 THEN wl = CSRLIN
IF wc = 0 AND dc = 0 THEN wc = POS(0)
tl = wl
tc = wc
IF wl = 0 OR wc = 0 THEN dc = 1
LOCATE wl, wc
IF wcirc = 4 THEN PRINT "\";
IF wcirc = 3 THEN PRINT "-";
IF wcirc = 2 THEN PRINT "/";
IF wcirc = 1 THEN PRINT "|";
wcirc = wcirc + 1
IF wcirc = 5 THEN wcirc = 1
ndw:
END SUB