REM File: Dndsic1 for Dndbbs Version v5.0a Release r2.0 Tweak t6.0a

' get standard include declarations
REM $INCLUDE: 'DNDSIC.INC'

SUB Enter.Equate
 On Local Error Goto Equate.Error
 Allow.Extra = False
 Out2 = STRIM$(Out2)
 IF Out2 = Nul THEN
    EXIT SUB
 END IF
 Store.Input$ = Out2
 CALL Assignment
 IF Assign THEN
    EXIT SUB
 END IF
 Out2 = Store.Input$
 PName$ = UCASE$(Out2)

 Rem functions added after profile.dat written:
 If Left$(Pname$, 4) = "LOCK" Then
    IF UserProfile.Commands(106) = False Then ' open file
       Error 143
       Exit Sub
    END IF
    Call LockFile
    Exit Sub
 Endif

 If Left$(Pname$, 6) = "UNLOCK" Then
    IF UserProfile.Commands(106) = False Then ' open file
       Error 143
       Exit Sub
    END IF
    Call UnlockFile
    Exit Sub
 Endif

 If Left$(Pname$, 6) = "SQUARE" Then
    IF UserProfile.Commands(135) = False Then ' circle
       Error 143
       Exit Sub
    END IF
    Call DrawSquare
    Exit Sub
 Endif

 If Left$(Pname$, 8) = "TRIANGLE" Then
    IF UserProfile.Commands(135) = False Then ' circle
       Error 143
       Exit Sub
    END IF
    Call DrawTriangle
    Exit Sub
 Endif

 If Left$(Pname$, 7) = "POLYGON" Then
    IF UserProfile.Commands(135) = False Then ' circle
       Error 143
       Exit Sub
    END IF
    Call DrawPolygon
    Exit Sub
 Endif

 Rem code for all remaining functions:
 FOR PNumber = 1 TO 138
    SName$ = RTRIM$(Statements(PNumber))
    IF LEFT$(PName$, LEN(SName$)) = SName$ THEN
       IF LEN(PName$) > LEN(SName$) THEN
          IF RIGHT$(SName$, 1) <> "#" THEN
             Bad.Token = False
             Token.Form$ = MID$(PName$, LEN(SName$) + 1, 1)
             SELECT CASE Token.Form$
             CASE "(", "[", "{"
                Token = 2
             CASE "="
                IF RIGHT$(SName$, 1) = "$" THEN
                   Token = 1
                ELSE
                   Bad.Token = True
                END IF
             CASE " "
                Token = False
             CASE ELSE
                Bad.Token = True
             END SELECT
             IF BadToken THEN
                SELECT CASE PNumber
                CASE 1, 5, 117  ' rem/data
                   Eat$ = Nul
                CASE ELSE
                   Strng = "<unknown statement>"
                   ERROR 92
                END SELECT
             END IF
          END IF
       END IF
       IF UserProfile.Commands(PNumber) = False Then
          Error 143
          Exit Sub
       END IF
       SELECT CASE PNumber
       CASE 1 ' Apostrophe
          Eat$ = Nul
       CASE 2, 3 ' Endif/End if
          Eat$ = Nul
       CASE 4 ' stop
	  Program.Line = Max.Lines
       CASE 5 ' REM
          Out2 = MID$(Out2, 4)
	  Out2 = STRIM$(Out2)
          Out2 = UCASE$(Out2)
          Out2 = XTRIM$(Out2, False) ' trim spaces
          ' REM $metacommand
          If Left$(Out2,7) = "$DEBUG:" Then
             Call Debug.Command(0, 0)
             Exit Sub
          Endif
          If Left$(Out2, 8) = "$LLINES:" Then
             Call DebugCommand2(0)
             Exit Sub
          End If
          If Left$(Out2,1)="$" Then
             If Left$(Out2,9) = "$INCLUDE:" Then
                Error 159
                Exit Sub
             Endif
             Select Case Out2
             Case "$DYNAMIC"
                Eat$=Nul
             Case "$STATIC"
                Eat$=Nul
             Case "$INHERIT"
                Eat$=Nul
             Case Else
                Error 160
                Exit Sub
             End Select
          Endif
       CASE 6
          CALL Assign.Mid.String
       CASE 7
          CALL Assign.Left.String
       CASE 8
          CALL Assign.Right.String
       CASE 9
          CALL Print.Expression.File
       CASE 10
          CALL Dprint.Expression
       CASE 11
          CALL Lprint.Expression
       CASE 12
          CALL Sprint.Expression
       CASE 13
          CALL Uprint.Expression
       CASE 14
          CALL Input.Expression(1)
       CASE 15
	  GOSUB Forif.Loop
       CASE 16
	  GOSUB Loop.Expression
       CASE 17
	  GOSUB Loopif.Terminate
       CASE 18
	  GOSUB Loop.Terminate
       CASE 19
	  GOSUB Continue.Forif
       CASE 20
	  GOSUB Continue.For
       CASE 21
	  GOSUB Exitif.For
       CASE 22
	  GOSUB Exit.For
       CASE 23 ' Do.Until
          Eat$ = Nul
       CASE 24
	  GOSUB End.Do.While
       CASE 25
	  GOSUB Exit.Do
       CASE 26
	  GOSUB Continue.Do
       CASE 27
	  GOSUB Branch.To
       CASE 28
	  GOSUB Gosub.Branch
       CASE 29
	  GOSUB Return.Branch
       CASE 30
	  GOSUB Do.While
       CASE 31 ' Do
          Eat$ = Nul
       CASE 32
	  Program.Line = Max.Lines
       CASE 33
	  GOSUB If.Branch
       CASE 34
	  GOSUB Else.Branch
       CASE 35
	  GOSUB Selectif.End
       CASE 36
	  GOSUB Selectif.End
       CASE 37
	  GOSUB Select.Case
       CASE 38 ' End Select
          Eat$ = Nul
       CASE 39
          Sound Freq, Duration
          Call Put.Modem(Chr$(7))
       CASE 40
          CALL Sound.Speaker
       CASE 41
          CALL Change.Color
       CASE 42
          CALL Locate.Cursor
       CASE 43
          CALL CLS.Screen
       CASE 44
          CALL Change.Screen
       CASE 45
          CALL Change.Width
       CASE 46
          CALL Write.Expression.File
       CASE 47
          CALL Line.Input.Expression(1)
       CASE 48
          CALL Line.Input.Exp.File
       CASE 49
          CALL Input.Expression.File
       CASE 50
	  GOSUB End.While
       CASE 51
	  GOSUB Do.Wend
       CASE 52
	  GOSUB Continue.While
       CASE 53
	  GOSUB Exit.While
       CASE 54
	  GOSUB Else.Branch
       CASE 55
	  GOSUB End.Do.Until
       CASE 56
	  GOSUB Loopif.Start
       CASE 57
	  GOSUB Endloop.If
       CASE 58
	  GOSUB Exitloop.If
       CASE 59
	  GOSUB End.Do
       CASE 60
          CALL Seed.Random
       CASE 61
          CALL Poke.Value
       CASE 62
          CALL Int86.Function
       CASE 63
          CALL Defseg.Function
       CASE 64
          CALL Absolute.Function
       CASE 65
          CALL Output.Port
       CASE 66
          CALL Wait.Port
       CASE 67
          CALL Sleep.Second
       CASE 68
          CALL Pause.Second
       CASE 69
	  GOSUB Selectif.Case
       CASE 70 ' End Selectif
          Eat$ = Nul
       CASE 71
	  GOSUB Select.End
       CASE 72
	  GOSUB Select.End
       CASE 73
	  GOSUB Continue.Loopif
       CASE 74 ' end
	  Program.Line = Max.Lines
       CASE 75 ' clear
          Close
          For Var2=0 To MaxFNs
             Definitions(Var2)=Nul
          Next
       CASE 76 ' system
          Account.Active = False
	  Program.Line = Max.Lines
          CALL Write.Account
          Call Terminate.Program
          END 2
       CASE 77
          CALL Swap.Data
       CASE 78
	  Out2 = MID$(Out2, 6)
	  Out2 = STRIM$(Out2)
	  Token.Index = 1
	  CALL Get.Token
	  CALL Parse1(Temp3#)
          If Temp3#>=0# And Temp3#<=255# Then
             ERROR Temp3#
          Else
             Error 5
          Endif
       CASE 79
	  Out2 = MID$(Out2, 14)
	  Out2 = STRIM$(Out2)
	  Token.Index = 1
	  CALL Get.Token
	  CALL Parse1(Temp3#)
	  ErrorType = CINT(Temp3#)
       CASE 80
          ErrorType=-1
       CASE 81
          ErrorType=-2
       CASE 82
          ErrorType=-3
       CASE 83
          ErrorType=False
       CASE 84 ' resume previous
          IF ErrorLine > 0 THEN
             Program.Line = ErrorLine - 1
             DO
                IF LEN(STRIM$(Program(Program.Line))) THEN
                   Program.Line = Program.Line - 1
                   EXIT DO
                END IF
                Program.Line = Program.Line - 1
                IF Program.Line < 1 THEN
                   Program.Line = Max.Lines
                   EXIT DO
                END IF
             LOOP
             ErrorLine = 0
          ELSE
             ERROR 20
          END IF
       CASE 85 ' resume same
          IF ErrorLine > 0 THEN
             Program.Line = ErrorLine - 1
             ErrorLine = 0
          ELSE
             ERROR 20
          END IF
       CASE 86 ' resume next
          IF ErrorLine > 0 THEN
             Program.Line = ErrorLine + 1
             DO
                IF LEN(STRIM$(Program(Program.Line))) THEN
                   Program.Line = Program.Line - 1
                   EXIT DO
                END IF
                Program.Line = Program.Line + 1
                IF Program.Line > Last.Line THEN
                   EXIT DO
                END IF
             LOOP
             ErrorLine = 0
          ELSE
             ERROR 20
          END IF
       CASE 87 ' resume
          IF ErrorLine > 0 THEN
             Out2 = MID$(Out2, 7)
             Out2 = STRIM$(Out2)
             IF Out2 = Nul THEN
                Program.Line = ErrorLine - 1
             ELSE
                Temp3# = INT(VAL(Out2)+.5)
                IF Temp3# <= 0# THEN
                   Program.Line = ErrorLine - 1
                ELSE
                   IF Temp3# <= Max.Lines THEN
                      Program.Line = CINT(Temp3#) - 1
                   ELSE
                      Program.Line = Max.Lines
                   END IF
                END IF
             END IF
             ErrorLine = 0
          ELSE
             ERROR 20
          END IF
       CASE 88
	  GOSUB Multi.Branch
       CASE 89
          CALL Set.Date
       CASE 90
          CALL Set.Time
       CASE 91
          CALL Change.Drive
       CASE 92
          CALL CD.Directory(1)
       CASE 93
          CALL CD.Directory(2)
       CASE 94
          CALL MD.Directory(1)
       CASE 95
          CALL MD.Directory(2)
       CASE 96
          CALL RD.Directory(1)
       CASE 97
          CALL RD.Directory(2)
       CASE 98
          CALL Kill.File(1)
       CASE 99
          CALL Kill.File(2)
       CASE 100
          CALL Name.Expression(1)
       CASE 101
          CALL Name.Expression(2)
       CASE 102
          CALL Shell.Program
       CASE 103
          CALL Chain.Program
       CASE 104
          CALL Assign.Keyword
       CASE 105
          CALL Close.File(1)
       CASE 106
          CALL Open.File
       CASE 107
          CALL Open.Field
       CASE 108
          CALL Write.Expression
       CASE 109
          CALL Print.Expression
       CASE 110
          CALL Input.Expression(2)
       CASE 111
          CALL Line.Input.Expression(2)
       CASE 112
          CALL Field.Set(1)
       CASE 113
          CALL Field.Set(2)
       CASE 114
          CALL Put.Record
       CASE 115
          CALL Get.Record
       CASE 116
          CALL Read.Record
       CASE 117 ' Data
          Eat$ = Nul
       CASE 118
          CALL Read.Data
       CASE 119
          CALL Restore.Data
       CASE 120
          CALL Draw.Circle.Step
       CASE 121
          CALL Draw.Line.Step
       CASE 122
          CALL Draw.Pixel
       CASE 123
          CALL Draw.PixelX
       CASE 124
          CALL Paint.Area
       CASE 125
          CALL Draw.Expression
       CASE 126
          CALL Play.Expression
       CASE 127
          CALL Get.Graphics
       CASE 128
          CALL Put.Graphics
       CASE 129
          CALL BSave.Image
       CASE 130
          CALL BLoad.Image
       CASE 131
          CALL View.Screen(1)
       CASE 132
          CALL View.Screen(2)
       CASE 133
          CALL Window.Screen(1)
       CASE 134
          CALL Window.Screen(2)
       CASE 135
          CALL Draw.Circle
       CASE 136
          CALL Draw.Line
       CASE 137
          CALL Close.File(2)
       CASE 138 ' DEF FN
          CALL Define.Function
       END SELECT
       EXIT SUB
    END IF
 NEXT
 ERROR 91
Equate.Exit:
 EXIT SUB

Forif.Loop:
 Out2 = MID$(Out2, 6)
 Out2 = STRIM$(Out2)
 Token.Index = 1
 CALL Get.Token
 CALL Parse1(Temp4#)
 IF Strng = "," THEN
    IF Temp4# THEN
       Out2 = UCASE$(MID$(Out2, Token.Index))
       Out2 = STRIM$(Out2)
       Temp1$ = UCASE$(LEFT$(Out2, 1))
       IF Temp1$ >= "A" AND Temp1$ <= "Z" THEN
	  Element = ASC(Temp1$) - 64
	  Out2 = MID$(Out2, 2)
	  Out2 = STRIM$(Out2)
	  IF LEFT$(Out2, 1) = "=" THEN
	     Out2 = MID$(Out2, 2)
	     Out2 = STRIM$(Out2)
	     FinishFor = Dfalse
	     StepTo = 1#
	     ExceptStep = Dfalse
             ExceptStepIs = False
	     CALL Equate(StartFor#)
	     Variables(Element) = StartFor#
             IF ExceptStepIs THEN
                IF StartFor# = ExceptStep THEN
                   IF StartFor# = FinishFor THEN
                      GOTO Loopif.Ignore
                   ELSE
                      GOSUB Loopif.Ignore
                      Program.Line = Program.Line - 1
                      RETURN
                   END IF
		END IF
	     END IF
	     IF StepTo > Dfalse THEN
		IF StartFor# > FinishFor THEN
		   GOTO Loopif.Ignore
		END IF
	     END IF
	     IF StepTo < Dfalse THEN
		IF StartFor# < FinishFor THEN
		   GOTO Loopif.Ignore
		END IF
	     END IF
	     RETURN
	  END IF
       END IF
    ELSE
       GOTO Loopif.Ignore
    END IF
    RETURN
 END IF
 ERROR 103
 RETURN

Loopif.Ignore:
 FOR Count1 = Program.Line + 1 TO Last.Line
    GOSUB Imbeddedif.Ignore
    IF Imbedded THEN
       GOTO Loopif.Ignore
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 6)) = "NEXTIF" THEN
       Program.Line = Count1
       RETURN
    END IF
 NEXT
 ERROR 103
 RETURN

Imbeddedif.Ignore:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 5)) <> "FORIF" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 < Last.Line
    Count2 = Count2 + 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 5)) = "FORIF" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 6)) = "NEXTIF" THEN
       Nested = Nested - 1
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 103
 RETURN

Loopif.Terminate:
 For.Loop = Program.Line
Nextif.For:
 FOR Count1 = Program.Line - 1 TO 1 STEP -1
    GOSUB Imbeddedif.For
    IF Imbedded THEN
       GOTO Nextif.For
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 5)) = "FORIF" THEN
       Out2 = MID$(Temp1$, 6)
       Out2 = STRIM$(Out2)
       Token.Index = 1
       CALL Get.Token
       CALL Parse1(Temp4#)
       IF Strng = "," THEN
	  IF Temp4# THEN
             Out2 = UCASE$(MID$(Out2, Token.Index))
	     Out2 = STRIM$(Out2)
	     Temp1$ = UCASE$(LEFT$(Out2, 1))
	     IF Temp1$ >= "A" AND Temp1$ <= "Z" THEN
		Element = ASC(Temp1$) - 64
                Out2 = MID$(Out2, 2)
                Out2 = STRIM$(Out2)
                IF LEFT$(Out2, 1) = "=" THEN
                   Out2 = MID$(Out2, 2)
                   Out2 = STRIM$(Out2)
                   FinishFor = Dfalse
                   StepTo = 1#
                   ExceptStep = Dfalse
                   ExceptStepIs = False
                   CALL Equate(X#)
                   Variable# = Variables(Element)
                   Variable# = Variable# + StepTo
                   Variables(Element) = Variable#
                   IF ExceptStepIs THEN
                      IF Variable# = ExceptStep THEN
                         Program.Line = For.Loop - 1
                         RETURN
                      END IF
                   END IF
                   IF StepTo > Dfalse THEN
                      IF Variable# <= FinishFor THEN
                         Program.Line = Count1
                      ELSE
                         Program.Line = For.Loop
                      END IF
                      RETURN
                   ELSE
                      IF StepTo < Dfalse THEN
                         IF Variable# >= FinishFor THEN
                            Program.Line = Count1
                         ELSE
                            Program.Line = For.Loop
                         END IF
                         RETURN
                      END IF
                   END IF
		END IF
	     END IF
	  ELSE
	     Program.Line = Count1
	  END IF
	  RETURN
       END IF
       ERROR 103
       RETURN
    END IF
 NEXT
 ERROR 103
 RETURN

Imbeddedif.For:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 6)) <> "NEXTIF" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 > 1
    Count2 = Count2 - 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 6)) = "NEXTIF" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 5)) = "FORIF" THEN
       Nested = Nested - 1
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 103
 RETURN

Continue.Forif:
 Nested = 1
 Out2 = MID$(Out2, 15)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 5)) = "FORIF" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 6)) = "NEXTIF" THEN
       Nested = Nested - 1
       IF Nested = False THEN
	  Program.Line = Count1 - 1
	  RETURN
       END IF
    END IF
 NEXT
 ERROR 103
 RETURN

Exitif.For:
 Nested = 1
 Out2 = MID$(Out2, 11)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 5)) = "FORIF" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 6)) = "NEXTIF" THEN
       Nested = Nested - 1
       IF Nested = False THEN
	  Program.Line = Count1
	  RETURN
       END IF
    END IF
 NEXT
 ERROR 103
 RETURN

Loop.Expression:
 Out2 = MID$(Out2, 4)
 Out2 = STRIM$(Out2)
 Temp1$ = UCASE$(LEFT$(Out2, 1))
 IF Temp1$ >= "A" AND Temp1$ <= "Z" THEN
    Element = ASC(Temp1$) - 64
    Out2 = MID$(Out2, 2)
    Out2 = STRIM$(Out2)
    IF LEFT$(Out2, 1) = "=" THEN
       Out2 = MID$(Out2, 2)
       Out2 = STRIM$(Out2)
       FinishFor = Dfalse
       StepTo = 1#
       ExceptStep = Dfalse
       ExceptStepIs = False
       CALL Equate(StartFor#)
       Variables(Element) = StartFor#
       IF ExceptStepIs THEN
          IF StartFor# = ExceptStep THEN
             IF StartFor# = FinishFor THEN
                GOTO Loop.Ignore
             ELSE
                GOSUB Loop.Ignore
                Program.Line = Program.Line - 1
                RETURN
             END IF
	  END IF
       END IF
       IF StepTo > Dfalse THEN
	  IF StartFor# > FinishFor THEN
	     GOTO Loop.Ignore
	  END IF
       END IF
       IF StepTo < Dfalse THEN
	  IF StartFor# < FinishFor THEN
	     GOTO Loop.Ignore
	  END IF
       END IF
       RETURN
    END IF
 END IF
 ERROR 97
 RETURN

Loop.Ignore:
 FOR Count1 = Program.Line + 1 TO Last.Line
    GOSUB Imbedded.Ignore
    IF Imbedded THEN
       GOTO Loop.Ignore
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 4)) = "NEXT" THEN
       IF UCASE$(LEFT$(Temp1$, 6)) <> "NEXTIF" THEN
          Program.Line = Count1
          RETURN
       END IF
    END IF
 NEXT
 ERROR 97
 RETURN

Imbedded.Ignore:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 5)) <> "FORIF" THEN
    RETURN
 END IF
 IF UCASE$(LEFT$(Temp1$, 3)) <> "FOR" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 < Last.Line
    Count2 = Count2 + 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 3)) = "FOR" THEN
       IF UCASE$(LEFT$(Temp1$, 5)) <> "FORIF" THEN
          Nested = Nested + 1
       END IF
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "NEXT" THEN
       IF UCASE$(LEFT$(Temp1$, 6)) <> "NEXTIF" THEN
          Nested = Nested - 1
       END IF
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 97
 RETURN

Loop.Terminate:
 For.Loop = Program.Line
Next.For:
 FOR Count1 = Program.Line - 1 TO 1 STEP -1
    GOSUB Imbedded.For
    IF Imbedded THEN
       GOTO Next.For
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 3)) = "FOR" THEN
       IF UCASE$(LEFT$(Temp1$, 5)) <> "FORIF" THEN
          Temp1$ = MID$(Temp1$, 4)
          Temp1$ = STRIM$(Temp1$)
          Temp2$ = UCASE$(LEFT$(Temp1$, 1))
          IF Temp2$ >= "A" AND Temp2$ <= "Z" THEN
             Element = ASC(Temp2$) - 64
             Out2 = MID$(Temp1$, 2)
             Out2 = STRIM$(Out2)
             IF LEFT$(Out2, 1) = "=" THEN
                Out2 = MID$(Out2, 2)
                Out2 = STRIM$(Out2)
                FinishFor = Dfalse
                StepTo = 1#
                ExceptStep = Dfalse
                ExceptStepIs = False
                CALL Equate(X#)
                Variable# = Variables(Element)
                Variable# = Variable# + StepTo
                Variables(Element) = Variable#
                IF ExceptStepIs THEN
                   IF Variable# = ExceptStep THEN
                      Program.Line = For.Loop - 1
                      RETURN
                   END IF
                END IF
                IF StepTo > Dfalse THEN
                   IF Variable# <= FinishFor THEN
                      Program.Line = Count1
                   ELSE
                      Program.Line = For.Loop
                   END IF
                   RETURN
                ELSE
                   IF StepTo < Dfalse THEN
                      IF Variable# >= FinishFor THEN
                         Program.Line = Count1
                      ELSE
                         Program.Line = For.Loop
                      END IF
                      RETURN
                   END IF
                END IF
             END IF
          END IF
       END IF
    END IF
 NEXT
 ERROR 97
 RETURN

Imbedded.For:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 6)) = "NEXTIF" THEN
    RETURN
 END IF
 IF UCASE$(LEFT$(Temp1$, 4)) <> "NEXT" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 > 1
    Count2 = Count2 - 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 4)) = "NEXT" THEN
       IF UCASE$(LEFT$(Temp1$, 6)) <> "NEXTIF" THEN
          Nested = Nested + 1
       END IF
    END IF
    IF UCASE$(LEFT$(Temp1$, 3)) = "FOR" THEN
       IF UCASE$(LEFT$(Temp1$, 5)) <> "FORIF" THEN
          Nested = Nested - 1
       END IF
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 97
 RETURN

Continue.For:
 Nested = 1
 Out2 = MID$(Out2, 13)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 3)) = "FOR" THEN
       IF UCASE$(LEFT$(Temp1$, 5)) <> "FORIF" THEN
          Nested = Nested + 1
       END IF
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "NEXT" THEN
       IF UCASE$(LEFT$(Temp1$, 6)) <> "NEXTIF" THEN
          Nested = Nested - 1
          IF Nested = False THEN
             Program.Line = Count1 - 1
             RETURN
          END IF
       END IF
    END IF
 NEXT
 ERROR 97
 RETURN

Exit.For:
 Nested = 1
 Out2 = MID$(Out2, 9)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 3)) = "FOR" THEN
       IF UCASE$(LEFT$(Temp1$, 5)) <> "FORIF" THEN
          Nested = Nested + 1
       END IF
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "NEXT" THEN
       IF UCASE$(LEFT$(Temp1$, 6)) <> "NEXTIF" THEN
          Nested = Nested - 1
          IF Nested = False THEN
             Program.Line = Count1
             RETURN
          END IF
       END IF
    END IF
 NEXT
 ERROR 97
 RETURN

End.Do.While:
 Out2 = MID$(Out2, 11)
 Out2 = STRIM$(Out2)
 CALL Equate(Temp3#)
 IF Temp3# = Dtrue THEN
    GOTO End.Do
 END IF
 RETURN
End.Do.Until:
 Out2 = MID$(Out2, 11)
 Out2 = STRIM$(Out2)
 CALL Equate(Temp3#)
 IF Temp3# = Dfalse THEN
    GOTO End.Do
 END IF
 RETURN
End.Do:
 Loop.Line = Program.Line
Next.Do:
 FOR Count1 = Program.Line - 1 TO 1 STEP -1
    GOSUB Imbedded.Loop
    IF Imbedded THEN
       GOTO Next.Do
    END IF
    Temp1$ = STRIM$(Program(Count1))
    IF UCASE$(LEFT$(Temp1$, 2)) = "DO" THEN
       IF UCASE$(LEFT$(Temp1$, 8)) = "DO WHILE" THEN
	  Out2 = MID$(Temp1$, 9)
	  Out2 = STRIM$(Out2)
	  CALL Equate(Temp3#)
	  IF Temp3# = Dfalse THEN
	     Program.Line = Loop.Line
	  ELSE
	     Program.Line = Count1
	  END IF
	  RETURN
       ELSE
	  IF UCASE$(LEFT$(Temp1$, 8)) = "DO UNTIL" THEN
	     Out2 = MID$(Temp1$, 9)
	     Out2 = STRIM$(Out2)
	     CALL Equate(Temp3#)
	     IF Temp3# <> Dfalse THEN
		Program.Line = Loop.Line
	     ELSE
		Program.Line = Count1
	     END IF
	     RETURN
	  ELSE
	     Program.Line = Count1
	     RETURN
	  END IF
       END IF
    END IF
 NEXT
 ERROR 98
 RETURN

Loopif.Start:
 Unless.Branch = False
 Out2 = MID$(Out2, 7)
 Out2 = STRIM$(Out2)
 IF Out2 = Nul THEN
    ERROR 104
 END IF
 CALL Equate(Temp3#)
 IF Temp3# THEN
    IF Unless.Branch = False THEN
       RETURN
    ELSE
       IF Unless.Value = Dfalse THEN
	  RETURN
       END IF
    END IF
 END IF
 Nested = 1
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 6)) = "LOOPIF" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 10)) = "END LOOPIF" THEN
       Nested = Nested - 1
       IF Nested = False THEN
	  Program.Line = Count1
	  RETURN
       END IF
    END IF
 NEXT
 ERROR 104
 RETURN

Endloop.If:
 Loop.Line = Program.Line
Next.Ifdo:
 FOR Count1 = Program.Line - 1 TO 1 STEP -1
    GOSUB Imbedded.Loopif
    IF Imbedded THEN
       GOTO Next.Ifdo
    END IF
    Temp1$ = STRIM$(Program(Count1))
    IF UCASE$(LEFT$(Temp1$, 6)) = "LOOPIF" THEN
       Out2 = MID$(Temp1$, 7)
       Out2 = STRIM$(Out2)
       CALL Equate(Temp3#)
       IF Temp3# = Dfalse THEN
	  Program.Line = Loop.Line
       ELSE
	  Program.Line = Count1
       END IF
       RETURN
    END IF
 NEXT
 ERROR 104
 RETURN

Exitloop.If:
 Nested = 1
 Out2 = MID$(Out2, 12)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 6)) = "LOOPIF" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 10)) = "END LOOPIF" THEN
       Nested = Nested - 1
       IF Nested = False THEN
	  Program.Line = Count1
	  RETURN
       END IF
    END IF
 NEXT
 ERROR 104
 RETURN

Imbedded.Loopif:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 10)) <> "END LOOPIF" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 > 1
    Count2 = Count2 - 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 10)) = "END LOOPIF" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 6)) = "LOOPIF" THEN
       Nested = Nested - 1
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 104
 RETURN

Continue.Loopif:
 Nested = 1
 Out2 = MID$(Out2, 16)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 6)) = "LOOPIF" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 10)) = "END LOOPIF" THEN
       Nested = Nested - 1
       IF Nested = False THEN
	  Program.Line = Count1 - 1
	  RETURN
       END IF
    END IF
 NEXT
 ERROR 104
 RETURN

Imbedded.Loop:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 6)) = "LOOPIF" THEN
    RETURN
 END IF
 IF UCASE$(LEFT$(Temp1$, 4)) <> "LOOP" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 > 1
    Count2 = Count2 - 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 4)) = "LOOP" THEN
       IF UCASE$(LEFT$(Temp1$, 6)) <> "LOOPIF" THEN
          Nested = Nested + 1
       END IF
    END IF
    IF UCASE$(LEFT$(Temp1$, 2)) = "DO" THEN
       Nested = Nested - 1
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 98
 RETURN

Continue.Do:
 Nested = 1
 Out2 = MID$(Out2, 12)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 2)) = "DO" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "LOOP" THEN
       IF UCASE$(LEFT$(Temp1$, 6)) <> "LOOPIF" THEN
          Nested = Nested - 1
          IF Nested = False THEN
             Program.Line = Count1 - 1
             RETURN
          END IF
       END IF
    END IF
 NEXT
 ERROR 98
 RETURN

Exit.Do:
 Nested = 1
 Out2 = MID$(Out2, 8)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 2)) = "DO" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "LOOP" THEN
       IF UCASE$(LEFT$(Temp1$, 6)) <> "LOOPIF" THEN
          Nested = Nested - 1
          IF Nested = False THEN
             Program.Line = Count1
             RETURN
          END IF
       END IF
    END IF
 NEXT
 ERROR 98
 RETURN

Branch.To:
 Out2 = MID$(Out2, 5)
 Out2 = STRIM$(Out2)
 CALL Equate(Temp3#)
 Branch.Loop = CINT(Temp3#)
 IF Branch.Loop > False AND Branch.Loop <= Last.Line THEN
    Temp1$ = STRIM$(Program(Branch.Loop))
    IF Temp1$ <> Nul THEN
       Program.Line = Branch.Loop - 1
       RETURN
    END IF
 END IF
 ERROR 99
 RETURN

Gosub.Branch:
 Out2 = MID$(Out2, 6)
 Out2 = STRIM$(Out2)
 CALL Equate(Temp3#)
 Branch.Loop = CINT(Temp3#)
 IF Branch.Loop > False AND Branch.Loop <= Last.Line THEN
    Temp1$ = STRIM$(Program(Branch.Loop))
    IF Temp1$ <> Nul THEN
       Nested.Gosub = Nested.Gosub + 1
       IF Nested.Gosub = Max.Gosubs THEN
          Max.Gosubs = Max.Gosubs + 1
	  REDIM PRESERVE GosubReturn(1 TO Max.Gosubs) AS INTEGER
       END IF
       If Nested.Gosub >= MaxNestGosub Then
          Error 156
          Exit Sub
       Endif
       GosubReturn(Nested.Gosub) = Program.Line
       Program.Line = Branch.Loop - 1
       RETURN
    END IF
 END IF
 ERROR 99
 RETURN

Return.Branch:
 IF Nested.Gosub > False THEN
    Program.Line = GosubReturn(Nested.Gosub)
    Nested.Gosub = Nested.Gosub - 1
    RETURN
 END IF
 ERROR 100
 RETURN

Do.While:
 Out2 = MID$(Out2, 9)
 Out2 = STRIM$(Out2)
 CALL Equate(Temp3#)
 IF Temp3# = Dfalse THEN
Do.Branch:
    FOR Count1 = Program.Line + 1 TO Last.Line
       GOSUB Imbedded.Do
       IF Imbedded THEN
	  GOTO Do.Branch
       END IF
       Temp1$ = Program(Count1)
       Temp1$ = STRIM$(Temp1$)
       IF UCASE$(LEFT$(Temp1$, 4)) = "LOOP" THEN
          IF UCASE$(LEFT$(Temp1$, 6)) <> "LOOPIF" THEN
             Program.Line = Count1
             RETURN
          END IF
       END IF
    NEXT
    ERROR 98
 END IF
 RETURN

Imbedded.Do:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 2)) <> "DO" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 < Last.Line
    Count2 = Count2 + 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 2)) = "DO" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "LOOP" THEN
       IF UCASE$(LEFT$(Temp1$, 6)) <> "LOOPIF" THEN
          Nested = Nested - 1
       END IF
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 98
 RETURN

Multi.Branch:
 Out2 = MID$(Out2, 3)
 Out2 = STRIM$(Out2)
 Branch.Index = False
 Branch.Number = False
 Branch.Type = False
 Next.Branch = INSTR(UCASE$(Out2), "GOTO")
 IF Next.Branch THEN
    Branch.Type = 1
    OutX$ = MID$(Out2, Next.Branch + 4)
    Out2 = LEFT$(Out2, Next.Branch - 1)
 ELSE
    Next.Branch = INSTR(UCASE$(Out2), "GOSUB")
    IF Next.Branch THEN
       Branch.Type = 2
       OutX$ = MID$(Out2, Next.Branch + 5)
       Out2 = LEFT$(Out2, Next.Branch - 1)
    END IF
 END IF
 IF Branch.Type = False THEN
    ERROR 99
 END IF
 Token.Index = 1
 CALL Get.Token
 CALL Parse1(Temp3#)
 Branch.Index = CINT(Temp3#)
 IF Branch.Index <= False THEN
    EXIT SUB
 END IF
 IF Branch.Type = 1 THEN
    Token.Index = 1
    Out2 = OutX$
    CALL Get.Token
    CALL Parse1(Temp4#)
    FOR Index.Count = 1 TO Branch.Index - 1
       IF Strng <> "," THEN
          Temp4# = DFalse
          EXIT FOR
       END IF
       CALL Get.Token
       CALL Parse1(Temp4#)
    NEXT
    Branch.Number = CINT(Temp4#)
    IF Branch.Number = False THEN
       RETURN
    END IF
    IF Branch.Number > False AND Branch.Number <= Last.Line THEN
       Temp1$ = STRIM$(Program(Branch.Number))
       IF Temp1$ <> Nul THEN
          Program.Line = Branch.Number - 1
          RETURN
       END IF
    END IF
 ELSE
    IF Branch.Type = 2 THEN
       Token.Index = 1
       Out2 = OutX$
       CALL Get.Token
       CALL Parse1(Temp4#)
       FOR Index.Count = 1 TO Branch.Index - 1
          IF Strng <> "," THEN
             Temp4# = DFalse
             EXIT FOR
          END IF
          CALL Get.Token
          CALL Parse1(Temp4#)
       NEXT
       Branch.Number = CINT(Temp4#)
       IF Branch.Number = False THEN
          RETURN
       END IF
       IF Branch.Number > False AND Branch.Number <= Last.Line THEN
          Temp1$ = STRIM$(Program(Branch.Number))
          IF Temp1$ <> Nul THEN
             Nested.Gosub = Nested.Gosub + 1
             IF Nested.Gosub = Max.Gosubs THEN
                Max.Gosubs = Max.Gosubs + 1
                REDIM PRESERVE GosubReturn(1 TO Max.Gosubs) AS INTEGER
             END IF
             If Nested.Gosub >= MaxNestGosub Then
                Error 156
                Exit Sub
             Endif
             GosubReturn(Nested.Gosub) = Program.Line
             Program.Line = Branch.Number - 1
             RETURN
          END IF
       END IF
    END IF
 END IF
 ERROR 99
 RETURN

If.Branch:
 Unless.Branch = False
 Out2 = MID$(Out2, 3)
 Out2 = STRIM$(Out2)
 CALL Equate(Temp3#)
 IF Temp3# THEN
    IF Unless.Branch = False THEN
       RETURN
    ELSE
       IF Unless.Value = Dfalse THEN
	  RETURN
       END IF
    END IF
 END IF
Endif.Branch:
 FOR Count1 = Program.Line + 1 TO Last.Line
    GOSUB Imbedded.Endif
    IF Imbedded THEN
       GOTO Endif.Branch
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 6)) = "ELSEIF" THEN
       Program.Line = Count1
       Out2 = UCASE$(MID$(Temp1$, 5))
       GOTO If.Branch
       RETURN
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "ELSE" THEN
       Program.Line = Count1
       RETURN
    END IF
    IF UCASE$(LEFT$(Temp1$, 5)) = "ENDIF" OR UCASE$(LEFT$(Temp1$, 6)) = "END IF" THEN
       Program.Line = Count1
       RETURN
    END IF
 NEXT
 ERROR 99
 RETURN

Else.Branch:
 FOR Count1 = Program.Line + 1 TO Last.Line
    GOSUB Imbedded.Endif
    IF Imbedded THEN
       GOTO Else.Branch
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 5)) = "ENDIF" OR UCASE$(LEFT$(Temp1$, 6)) = "END IF" THEN
       Program.Line = Count1
       RETURN
    END IF
 NEXT
 ERROR 99
 RETURN

Imbedded.Endif:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 2)) <> "IF" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 < Last.Line
    Count2 = Count2 + 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 2)) = "IF" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 5)) = "ENDIF" OR UCASE$(LEFT$(Temp1$, 6)) = "END IF" THEN
       Nested = Nested - 1
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 99
 RETURN

Do.Wend:
 Out2 = MID$(Out2, 6)
 Out2 = STRIM$(Out2)
 CALL Equate(Temp3#)
 IF Temp3# = Dfalse THEN
While.Branch:
    FOR Count1 = Program.Line + 1 TO Last.Line
       GOSUB Imbedded.Wend
       IF Imbedded THEN
	  GOTO While.Branch
       END IF
       Temp1$ = Program(Count1)
       Temp1$ = STRIM$(Temp1$)
       IF UCASE$(LEFT$(Temp1$, 4)) = "WEND" THEN
	  Program.Line = Count1
	  RETURN
       END IF
    NEXT
    ERROR 98
 END IF
 RETURN

Imbedded.Wend:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 5)) <> "WHILE" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 < Last.Line
    Count2 = Count2 + 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 5)) = "WHILE" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "WEND" THEN
       Nested = Nested - 1
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 98
 RETURN

End.While:
 Loop.Line = Program.Line
Next.While:
 FOR Count1 = Program.Line - 1 TO 1 STEP -1
    GOSUB Imbedded.While
    IF Imbedded THEN
       GOTO Next.While
    END IF
    Temp1$ = STRIM$(Program(Count1))
    IF UCASE$(LEFT$(Temp1$, 5)) = "WHILE" THEN
       Out2 = MID$(Temp1$, 6)
       Out2 = STRIM$(Out2)
       CALL Equate(Temp3#)
       IF Temp3# = Dfalse THEN
	  Program.Line = Loop.Line
       ELSE
	  Program.Line = Count1
       END IF
       RETURN
    END IF
 NEXT
 ERROR 98
 RETURN

Imbedded.While:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 4)) <> "WEND" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 > 1
    Count2 = Count2 - 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 4)) = "WEND" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 5)) = "WHILE" THEN
       Nested = Nested - 1
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 98
 RETURN

Continue.While:
 Nested = 1
 Out2 = MID$(Out2, 15)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 5)) = "WHILE" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "WEND" THEN
       Nested = Nested - 1
       IF Nested = False THEN
	  Program.Line = Count1 - 1
	  RETURN
       END IF
    END IF
 NEXT
 ERROR 98
 RETURN

Exit.While:
 Nested = 1
 Out2 = MID$(Out2, 11)
 Out2 = STRIM$(Out2)
 IF LEN(Out2) THEN
    Last.Token = False
    Token.Index = 1
    CALL Get.Token
    CALL Parse1(Temp3#)
    IF Temp3# > Dfalse AND Temp3# <= 255 THEN
       Nested = CINT(Temp3#)
    END IF
 END IF
 FOR Count1 = Program.Line + 1 TO Last.Line
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 5)) = "WHILE" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 4)) = "WEND" THEN
       Nested = Nested - 1
       IF Nested = False THEN
	  Program.Line = Count1
	  RETURN
       END IF
    END IF
 NEXT
 ERROR 98
 RETURN

Select.End:
 FOR Count1 = Program.Line + 1 TO Last.Line
    GOSUB Imbedded.Select
    IF Imbedded THEN
       GOTO Select.End
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 12)) <> "END SELECTIF" THEN
       IF UCASE$(LEFT$(Temp1$, 10)) = "END SELECT" THEN
          Program.Line = Count1
          RETURN
       END IF
    END IF
 NEXT
 ERROR 102
 RETURN

Selectif.End:
 FOR Count1 = Program.Line + 1 TO Last.Line
    GOSUB Imbeddedif.Select
    IF Imbedded THEN
       GOTO Selectif.End
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 12)) = "END SELECTIF" THEN
       Program.Line = Count1
       RETURN
    END IF
 NEXT
 ERROR 105
 RETURN

Select.Case:
 Last.Token = False
 Out2 = MID$(Out2, 12)
 CALL Equate(Temp3#)
 IF Last.Token THEN
    CaseValue = Temp3#
 ELSE
    CaseStrng = Out3
 END IF
 Previous.Token = Last.Token
Next.Select.Case:
 FOR Count1 = Program.Line + 1 TO Last.Line
    GOSUB Imbedded.Select
    IF Imbedded THEN
       GOTO Next.Select.Case
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 12)) <> "END SELECTIF" THEN
       IF UCASE$(LEFT$(Temp1$, 10)) = "END SELECT" THEN
          Program.Line = Count1
          RETURN
       END IF
    END IF
    IF UCASE$(LEFT$(Temp1$, 9)) = "CASE ELSE" THEN
       Program.Line = Count1
       RETURN
    END IF
    IF UCASE$(LEFT$(Temp1$, 6)) <> "CASEIF" THEN
       IF UCASE$(LEFT$(Temp1$, 4)) = "CASE" THEN
          Out2 = MID$(Temp1$, 5)
          Out2 = STRIM$(Out2)
          Token.Index = 1
          DO
             IF Last.Token <> 1 THEN
                Last.Token = False
                CALL Get.Token
             END IF
             CALL Parse1(Temp4#)
             SELECT CASE Last.Token
             CASE -1
                IF CaseValue = Temp4# THEN
                   Program.Line = Count1
                   RETURN
                END IF
             CASE 0
                IF CaseStrng = Out3 THEN
                   Program.Line = Count1
                   RETURN
                END IF
             CASE 1
                IF ValueIs THEN
                   Program.Line = Count1
                   RETURN
                END IF
             CASE 2
                IF Previous.Token THEN
                   IF CaseValue >= CaseValue1 AND CaseValue <= CaseValue2 THEN
                      Program.Line = Count1
                      RETURN
                   END IF
                ELSE
                   IF CaseStrng >= CaseValueS1 AND CaseStrng <= CaseValueS2 THEN
                      Program.Line = Count1
                      RETURN
                   END IF
                END IF
             END SELECT
             IF Token.Index > LEN(Out2) THEN
                EXIT DO
             END IF
          LOOP
       END IF
    END IF
 NEXT
 ERROR 102
 RETURN

Selectif.Case:
 Out2 = MID$(Out2, 14)
 Out2 = STRIM$(Out2)
 Token.Index = 1
 CALL Get.Token
 CALL Parse1(Temp4#)
 IF Strng = "," THEN
    IF Temp4# THEN
       Out2 = UCASE$(MID$(Out2, Token.Index))
       Out2 = STRIM$(Out2)
       Last.Token = False
       CALL Equate(Temp3#)
       IF Last.Token THEN
	  CaseValue = Temp3#
       ELSE
	  CaseStrng = Out3
       END IF
       Previous.Token = Last.Token
Next.Selectif.Case:
       FOR Count1 = Program.Line + 1 TO Last.Line
	  GOSUB Imbeddedif.Select
	  IF Imbedded THEN
	     GOTO Next.Selectif.Case
	  END IF
	  Temp1$ = Program(Count1)
	  Temp1$ = STRIM$(Temp1$)
          IF UCASE$(LEFT$(Temp1$, 12)) = "END SELECTIF" THEN
	     Program.Line = Count1
	     RETURN
	  END IF
	  IF UCASE$(LEFT$(Temp1$, 11)) = "CASEIF ELSE" THEN
	     Program.Line = Count1
	     RETURN
	  END IF
	  IF UCASE$(LEFT$(Temp1$, 6)) = "CASEIF" THEN
	     Out2 = MID$(Temp1$, 7)
	     Out2 = STRIM$(Out2)
	     Token.Index = 1
	     DO
                IF Last.Token <> 1 THEN
                   Last.Token = False
                   CALL Get.Token
                END IF
		CALL Parse1(Temp4#)
		SELECT CASE Last.Token
		CASE -1
		   IF CaseValue = Temp4# THEN
		      Program.Line = Count1
		      RETURN
		   END IF
		CASE 0
		   IF CaseStrng = Out3 THEN
		      Program.Line = Count1
		      RETURN
		   END IF
		CASE 1
		   IF ValueIs THEN
		      Program.Line = Count1
		      RETURN
		   END IF
		CASE 2
		   IF Previous.Token THEN
		      IF CaseValue >= CaseValue1 AND CaseValue <= CaseValue2 THEN
			 Program.Line = Count1
			 RETURN
                      END IF
                   ELSE
		      IF CaseStrng >= CaseValueS1 AND CaseStrng <= CaseValueS2 THEN
			 Program.Line = Count1
			 RETURN
		      END IF
		   END IF
		END SELECT
		IF Token.Index > LEN(Out2) THEN
		   EXIT DO
		END IF
	     LOOP
	  END IF
       NEXT
    ELSE
       GOTO Selectif.Ignore
    END IF
    RETURN
 END IF
 ERROR 105
 RETURN

Selectif.Ignore:
 FOR Count1 = Program.Line + 1 TO Last.Line
    GOSUB Imbeddedselectif.Ignore
    IF Imbedded THEN
       GOTO Selectif.Ignore
    END IF
    Temp1$ = Program(Count1)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 12)) = "END SELECTIF" THEN
       Program.Line = Count1
       RETURN
    END IF
 NEXT
 ERROR 105
 RETURN

Imbeddedselectif.Ignore:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 13)) <> "SELECTIF CASE" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 < Last.Line
    Count2 = Count2 + 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 5)) = "SELECTIF CASE" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 6)) = "END SELECTIF" THEN
       Nested = Nested - 1
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 105
 RETURN

Imbedded.Select:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 11)) <> "SELECT CASE" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 < Last.Line
    Count2 = Count2 + 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 11)) = "SELECT CASE" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 12)) <> "END SELECTIF" THEN
       IF UCASE$(LEFT$(Temp1$, 10)) = "END SELECT" THEN
          Nested = Nested - 1
       END IF
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 102
 RETURN

Imbeddedif.Select:
 Imbedded = False
 Temp1$ = Program(Count1)
 Temp1$ = STRIM$(Temp1$)
 IF UCASE$(LEFT$(Temp1$, 13)) <> "SELECTIF CASE" THEN
    RETURN
 END IF
 Imbedded = True
 Nested = 1
 Count2 = Count1
 DO WHILE Count2 < Last.Line
    Count2 = Count2 + 1
    Temp1$ = Program(Count2)
    Temp1$ = STRIM$(Temp1$)
    IF UCASE$(LEFT$(Temp1$, 13)) = "SELECTIF CASE" THEN
       Nested = Nested + 1
    END IF
    IF UCASE$(LEFT$(Temp1$, 12)) = "END SELECTIF" THEN
       Nested = Nested - 1
    END IF
    IF Nested = False THEN
       Program.Line = Count2
       RETURN
    END IF
 LOOP
 ERROR 105
 RETURN

Equate.Error:
 Last.Error = Program.Line
 ErrorLine = Program.Line
 ErrorValue = ERR
 SELECT CASE ErrorType
 CASE -1
    DO
       Program.Line = Program.Line - 1
       IF LEN(STRIM$(Program(Program.Line))) THEN
          ErrorLine = 0
	  Program.Line = Program.Line - 1
	  RESUME Equate.Exit
       END IF
       IF Program.Line <= False THEN
	  EXIT DO
       END IF
    LOOP
    ErrorLine = 0
 CASE -2
    Program.Line = Program.Line - 1
    ErrorLine = 0
    RESUME Equate.Exit
 CASE -3
    DO
       Program.Line = Program.Line + 1
       IF LEN(STRIM$(Program(Program.Line))) THEN
	  Program.Line = Program.Line - 1
          ErrorLine = 0
	  RESUME Equate.Exit
       END IF
       IF Program.Line >= Last.Line THEN
          Program.Line = Last.Line
          ErrorLine = 0
	  RESUME Equate.Exit
       END IF
    LOOP
    ErrorLine = 0
 CASE 0
    Eat$ = Nul
 CASE IS>0
    Program.Line = ErrorType
    IF LEN(STRIM$(Program(Program.Line))) THEN
       Program.Line = Program.Line - 1
       RESUME Equate.Exit
    END IF
 END SELECT
 PrinterLF = False
 Printing = False
 Program.Line = Max.Lines
 ErrorValue = ERR
 Call Get.Cursor(VarX)
 IF VarX > 1 THEN
    Strng3 = NUL
    Call IO.O
 END IF
 Call Modem.ANSI(4,31,12)
 Call ScreenANSI(4,31,12)
 CALL Display.Error
 Call IO.O
 CALL Key.Prompt
 LineFeed = 0
 RESUME Equate.Exit
END SUB

SUB Assign.Keyword
 Temp1$ = UCASE$(MID$(Out2, 4))
 Temp1$ = STRIM$(Temp1$)
 Out2 = MID$(Out2, 4)
 Out2 = STRIM$(Out2)
 IF LEFT$(Temp1$, 3) = "MID" THEN
    CALL Assign.Mid.String
    EXIT SUB
 END IF
 IF LEFT$(Temp1$, 4) = "LEFT" THEN
    CALL Assign.Left.String
    EXIT SUB
 END IF
 IF LEFT$(Temp1$, 5) = "RIGHT" THEN
    CALL Assign.Right.String
    EXIT SUB
 END IF
 CALL Assignment
END SUB

SUB Assignment
 Assign = False
 Temp1$ = UCASE$(LEFT$(Out2, 1))
 IF Temp1$="?" THEN
    Temp1$ = LTRIM$(MID$(Out2,2))
    Temp2$ = LEFT$(Temp1$, 1)
    IF Temp2$ = "=" THEN
       Temp1$ = LTRIM$(MID$(Temp1$, 2))
       Out2 = Temp1$
       ' calculates expression w/o output
       Store.Input$ = Out2
       Recurse = 0
       CALL Enter.Equate
       Assign = True
       EXIT SUB
    END IF
 END IF
 IF Temp1$ >= "A" AND Temp1$ <= "Z" THEN
    Variable = ASC(Temp1$) - 64
    Temp1$ = LTRIM$(MID$(Out2, 2))
    Temp2$ = UCASE$(LEFT$(Temp1$, 1))
    IF Temp2$ >= "A" AND Temp2$ <= "Z" THEN
       Temp2$ = LTRIM$(MID$(Out2, 3))
       Var1$ = UCASE$(LEFT$(Temp2$, 1))
       IF Var1$ >= "A" AND Var1$ <= "Z" THEN
          Var1$ = MID$(Out2, 4)
          Var2$ = UCASE$(LEFT$(Var1$, 1))
          Var2$ = STRIM$(Var2$)
          IF LEFT$(Var2$, 1) = "=" THEN
             Var1$ = MID$(Var1$, 2)
             Var1$ = STRIM$(Var1$)
             Var2$ = UCASE$(LEFT$(Out2, 3))
             CALL Assignment4(Var1$, Var2$)
	     IF Assign THEN
                CALL Assign.End
                EXIT SUB
	     END IF
	  END IF
       ELSE
          IF Var1$ = "=" THEN
             Var1$ = MID$(Out2, INSTR(Out2, "=") + 1)
             Var1$ = STRIM$(Var1$)
             Var2$ = UCASE$(LEFT$(Out2, 2))
             CALL Assignment3(Var1$, Var2$) ' registers
	     IF Assign THEN
                CALL Assign.End
                EXIT SUB
	     END IF
	  END IF
       END IF
    END IF
    Temp1$ = STRIM$(Temp1$)
    CALL Assignment1(Temp1$, Variable)
    IF Assign THEN
       CALL Assign.End
       EXIT SUB
    END IF
    IF LEFT$(Temp1$, 1) = "$" THEN
       Temp1$ = MID$(Temp1$, 2)
       Temp1$ = STRIM$(Temp1$)
       IF LEFT$(Temp1$, 1) = "(" THEN
          Strng = "<bad string token>"
          ERROR 92
       END IF
       IF LEFT$(Temp1$, 1) = "[" THEN
          Strng = "<bad string token>"
          ERROR 92
       END IF
       IF LEFT$(Temp1$, 1) = "{" THEN
          Strng = "<bad string token>"
          ERROR 92
       END IF
       IF LEFT$(Temp1$, 1) = "=" THEN
	  Out2 = MID$(Temp1$, 2)
	  Out2 = STRIM$(Out2)
          Token.Index = 1
          CALL Get.Token
          CALL Parse1(Temp3#)
          IF Last.Token = False THEN
             Strngs(Variable) = Out3
             Assign = True
             CALL Assign.End
             EXIT SUB
          END IF
       END IF
    END IF
    IF LEFT$(Temp1$, 1) = "(" THEN
       Out2 = MID$(Temp1$, 2)
       Out2 = STRIM$(Out2)
       Last.Token = False
       Token.Index = 1
       CALL Get.Token
       CALL Parse1(Temp3#)
       If Strng<>")" Then
          Strng = "<bad closing token>"
          Error 92
       Endif
       IF Last.Token = True THEN
          Element = CINT(Temp3#)
          Temp1$ = MID$(Out2, Token.Index)
          Temp1$ = STRIM$(Temp1$)
          CALL Assignment2(Temp1$, Variable, Element)
          IF Assign THEN
             CALL Assign.End
             EXIT SUB
          END IF
       END IF
    END IF
    IF LEFT$(Temp1$, 1) = "[" THEN
       Out2 = MID$(Temp1$, 2)
       Out2 = STRIM$(Out2)
       Last.Token = False
       Token.Index = 1
       CALL Get.Token
       CALL Parse1(Temp3#)
       If Strng<>"]" Then
          Strng = "<bad closing token>"
          Error 92
       Endif
       IF Last.Token = True THEN
          Element = CINT(Temp3#)
          Temp1$ = MID$(Out2, Token.Index)
          Temp1$ = STRIM$(Temp1$)
          CALL Assignment2(Temp1$, Variable, Element)
          IF Assign THEN
             CALL Assign.End
             EXIT SUB
          END IF
       END IF
    END IF
    IF LEFT$(Temp1$, 1) = "{" THEN
       Out2 = MID$(Temp1$, 2)
       Out2 = STRIM$(Out2)
       Last.Token = False
       Token.Index = 1
       CALL Get.Token
       CALL Parse1(Temp3#)
       If Strng<>"}" Then
          Strng = "<bad closing token>"
          Error 92
       Endif
       IF Last.Token = True THEN
          Element = CINT(Temp3#)
          Temp1$ = MID$(Out2, Token.Index)
          Temp1$ = STRIM$(Temp1$)
          CALL Assignment2(Temp1$, Variable, Element)
          IF Assign THEN
             CALL Assign.End
             EXIT SUB
          END IF
       END IF
    END IF
 END IF
END SUB

SUB Assign.End
 IF LEN(Strng) THEN
    CALL Parse1(X#)
    Strng = "<extra token>"
    ERROR 92
 END IF
END SUB

SUB Assign.Mid.String
 Out2 = MID$(Out2, 4)
 IF LEN(Out2) THEN
    Out2 = STRIM$(Out2)
    Out2 = MID$(Out2, 3)
    Temp1$ = UCASE$(LEFT$(Out2, 1))
    IF Temp1$ >= "A" AND Temp1$ <= "Z" THEN
       Variable = ASC(Temp1$) - 64
       IF MID$(Out2, 2, 1) = "$" THEN
	  Out2 = MID$(Out2, 4)
	  Last.Token = False
	  Token.Index = 1
	  CALL Get.Token
	  CALL Parse1(Temp3#)
	  Start = CINT(Temp3#)
          IF Strng = "," THEN
             CALL Get.Token
             CALL Parse1(Temp3#)
             Length = CINT(Temp3#)
             Out2 = MID$(Out2, Token.Index)
             Out2 = STRIM$(Out2)
             IF LEFT$(Out2, 1) = "=" THEN
                Out2 = MID$(Out2, 2)
                Out2 = STRIM$(Out2)
                Token.Index = 1
                CALL Get.Token
                CALL Parse1(Temp3#)
                IF Last.Token = False THEN
                   IF Length = LEN(Out3) THEN
                      IF Start > LEN(Strngs(Variable)) THEN
                         Strngs(Variable) = Strngs(Variable) + Space$(Start - Len(Strngs(Variable)) - 1) + Out3
                      ELSE
                         MID$(Strngs(Variable), Start, Length) = Out3
                      END IF
                      Call Assign.End
                      EXIT SUB
                   END IF
                END IF
             END IF
	  END IF
       END IF
    END IF
 END IF
 Strng = "<bad string>"
 ERROR 92
END SUB

SUB Assign.Left.String
 Out2 = MID$(Out2, 5)
 IF LEN(Out2) THEN
    Out2 = STRIM$(Out2)
    Out2 = MID$(Out2, 3)
    Temp1$ = UCASE$(LEFT$(Out2, 1))
    IF Temp1$ >= "A" AND Temp1$ <= "Z" THEN
       Variable = ASC(Temp1$) - 64
       IF MID$(Out2, 2, 1) = "$" THEN
	  Out2 = MID$(Out2, 4)
	  Last.Token = False
	  Token.Index = 1
	  CALL Get.Token
	  CALL Parse1(Temp3#)
	  Start = CINT(Temp3#)
	  Out2 = MID$(Out2, Token.Index)
	  Out2 = STRIM$(Out2)
	  IF LEFT$(Out2, 1) = "=" THEN
	     Out2 = MID$(Out2, 2)
	     Out2 = STRIM$(Out2)
	     Token.Index = 1
	     CALL Get.Token
	     CALL Parse1(Temp3#)
             IF Last.Token = False THEN
                IF Start = LEN(Out3) THEN
                   IF Strngs(Variable) = Nul THEN
                      Strngs(Variable) = Out3
                      Call Assign.End
                      EXIT SUB
                   END IF
                   MID$(Strngs(Variable), 1, Start) = Out3
                   Call Assign.End
                   EXIT SUB
                END IF
             END IF
	  END IF
       END IF
    END IF
 END IF
 Strng = "<bad string>"
 ERROR 92
END SUB

SUB Assign.Right.String
 Out2 = MID$(Out2, 6)
 IF LEN(Out2) THEN
    Out2 = STRIM$(Out2)
    Out2 = MID$(Out2, 3)
    Temp1$ = UCASE$(LEFT$(Out2, 1))
    IF Temp1$ >= "A" AND Temp1$ <= "Z" THEN
       Variable = ASC(Temp1$) - 64
       IF MID$(Out2, 2, 1) = "$" THEN
	  Out2 = MID$(Out2, 4)
	  Last.Token = False
	  Token.Index = 1
	  CALL Get.Token
	  CALL Parse1(Temp3#)
	  Start = CINT(Temp3#)
	  Out2 = MID$(Out2, Token.Index)
	  Out2 = STRIM$(Out2)
	  IF LEFT$(Out2, 1) = "=" THEN
	     Out2 = MID$(Out2, 2)
	     Out2 = STRIM$(Out2)
	     Token.Index = 1
	     CALL Get.Token
	     CALL Parse1(Temp3#)
	     Length = LEN(Strngs(Variable)) - Start + 1
             IF Last.Token = False THEN
                IF Start = LEN(Out3) THEN
                   IF Strngs(Variable) = Nul THEN
                      Strngs(Variable) = Out3
                      Call Assign.End
                      EXIT SUB
                   END IF
                   MID$(Strngs(Variable), Length, Start) = Out3
                   Call Assign.End
                   EXIT SUB
                END IF
             END IF
	  END IF
       END IF
    END IF
 END IF
 Strng = "<bad string>"
 ERROR 92
END SUB

SUB Draw.Circle.Step
 Allow.Extra = True
 Xcoor1 = False
 Xcoor1.Set = False
 Ycoor1 = False
 Ycoor1.Set = False
 Radius = False
 Radius.Set = False
 Color.Code = False
 Color.Set = False
 Start.Circle = False
 Start.Set = False
 End.Circle = False
 End.Set = False
 Aspect = False
 Aspect.Set = False
 Out2 = MID$(Out2, 12)
 Out2 = STRIM$(Out2)
 Last.Token = False
 Out3 = Nul
 Token.Index = 1
 CALL Get.Token
 CALL Parse1(Temp3#)
 Xcoor1 = CINT(Temp3#)
 IF Last.Token THEN
    Xcoor1.Set = True
 END IF
 IF Strng = "," THEN
    Last.Token = False
    Out3 = Nul
    CALL Get.Token
    CALL Parse1(Temp3#)
    Ycoor1 = CINT(Temp3#)
    IF Last.Token THEN
       Ycoor1.Set = True
    END IF
    IF Strng = "," THEN
       Last.Token = False
       Out3 = Nul
       CALL Get.Token
       CALL Parse1(Temp3#)
       Radius = CINT(Temp3#)
       IF Last.Token THEN
	  Radius.Set = True
       END IF
       IF Strng = "," THEN
	  Last.Token = False
	  Out3 = Nul
	  CALL Get.Token
	  CALL Parse1(Temp3#)
	  Color.Code = CINT(Temp3#)
	  IF Last.Token THEN
	     Color.Set = True
	  END IF
	  IF Strng = "," THEN
	     Last.Token = False
	     Out3 = Nul
	     CALL Get.Token
	     CALL Parse1(Temp3#)
	     Start.Circle = CINT(Temp3#)
	     IF Last.Token THEN
		Start.Set = True
	     END IF
	     IF Strng = "," THEN
		Last.Token = False
		Out3 = Nul
		CALL Get.Token
		CALL Parse1(Temp3#)
		End.Circle = CINT(Temp3#)
		IF Last.Token THEN
		   End.Set = True
		END IF
		IF Strng = "," THEN
		   Last.Token = False
		   Out3 = Nul
		   CALL Get.Token
		   CALL Parse1(Temp3#)
		   Aspect = CINT(Temp3#)
		   IF Last.Token THEN
		      Aspect.Set = True
		   END IF
		END IF
	     END IF
	  END IF
       END IF
       IF Xcoor1.Set AND Ycoor1.Set AND Radius.Set THEN
	  IF Start.Set AND End.Set THEN
	     IF Color.Set THEN
		IF Aspect.Set THEN
		   CIRCLE STEP(Xcoor1, Ycoor1), Radius, Color.Code, Start.Circle, End.Circle, Aspect%
		ELSE
		   CIRCLE STEP(Xcoor1, Ycoor1), Radius, Color.Code, Start.Circle, End.Circle
		END IF
	     ELSE
		IF Aspect.Set THEN
		   CIRCLE STEP(Xcoor1, Ycoor1), Radius, , Start.Circle, End.Circle, Aspect
		ELSE
		   CIRCLE STEP(Xcoor1, Ycoor1), Radius, , Start.Circle, End.Circle
		END IF
	     END IF
	  ELSE
	     IF Start.Set OR End.Set THEN
		ERROR 39
	     ELSE
		IF Color.Set THEN
		   IF Aspect.Set THEN
		      CIRCLE STEP(Xcoor1, Ycoor1), Radius, Color.Code, , , Aspect
		   ELSE
		      CIRCLE STEP(Xcoor1, Ycoor1), Radius, Color.Code
		   END IF
		ELSE
		   IF Aspect.Set THEN
		      CIRCLE STEP(Xcoor1, Ycoor1), Radius, , , , Aspect
		   ELSE
		      CIRCLE STEP(Xcoor1, Ycoor1), Radius
		   END IF
		END IF
	     END IF
	  END IF
          EXIT SUB
       END IF
    END IF
 END IF
 ERROR 39
END SUB

SUB Draw.Circle
 Allow.Extra = True
 Xcoor1 = False
 Xcoor1.Set = False
 Ycoor1 = False
 Ycoor1.Set = False
 Radius = False
 Radius.Set = False
 Color.Code = False
 Color.Set = False
 Start.Circle = False
 Start.Set = False
 End.Circle = False
 End.Set = False
 Aspect = False
 Aspect.Set = False
 Out2 = MID$(Out2, 12)
 Out2 = STRIM$(Out2)
 Last.Token = False
 Out3 = Nul
 Token.Index = 1
 CALL Get.Token
 CALL Parse1(Temp3#)
 Xcoor1 = CINT(Temp3#)
 IF Last.Token THEN
    Xcoor1.Set = True
 END IF
 IF Strng = "," THEN
    Last.Token = False
    Out3 = Nul
    CALL Get.Token
    CALL Parse1(Temp3#)
    Ycoor1 = CINT(Temp3#)
    IF Last.Token THEN
       Ycoor1.Set = True
    END IF
    IF Strng = "," THEN
       Last.Token = False
       Out3 = Nul
       CALL Get.Token
       CALL Parse1(Temp3#)
       Radius = CINT(Temp3#)
       IF Last.Token THEN
	  Radius.Set = True
       END IF
       IF Strng = "," THEN
	  Last.Token = False
	  Out3 = Nul
	  CALL Get.Token
	  CALL Parse1(Temp3#)
	  Color.Code = CINT(Temp3#)
	  IF Last.Token THEN
	     Color.Set = True
	  END IF
	  IF Strng = "," THEN
	     Last.Token = False
	     Out3 = Nul
	     CALL Get.Token
	     CALL Parse1(Temp3#)
	     Start.Circle = CINT(Temp3#)
	     IF Last.Token THEN
		Start.Set = True
	     END IF
	     IF Strng = "," THEN
		Last.Token = False
		Out3 = Nul
		CALL Get.Token
		CALL Parse1(Temp3#)
		End.Circle = CINT(Temp3#)
		IF Last.Token THEN
		   End.Set = True
		END IF
		IF Strng = "," THEN
		   Last.Token = False
		   Out3 = Nul
		   CALL Get.Token
		   CALL Parse1(Temp3#)
		   Aspect = CINT(Temp3#)
		   IF Last.Token THEN
		      Aspect.Set = True
		   END IF
		END IF
	     END IF
	  END IF
       END IF
       IF Xcoor1.Set AND Ycoor1.Set AND Radius.Set THEN
	  IF Start.Set AND End.Set THEN
	     IF Color.Set THEN
		IF Aspect.Set THEN
		   CIRCLE (Xcoor1, Ycoor1), Radius, Color.Code, Start.Circle, End.Circle, Aspect%
		ELSE
		   CIRCLE (Xcoor1, Ycoor1), Radius, Color.Code, Start.Circle, End.Circle
		END IF
	     ELSE
		IF Aspect.Set THEN
		   CIRCLE (Xcoor1, Ycoor1), Radius, , Start.Circle, End.Circle, Aspect
		ELSE
		   CIRCLE (Xcoor1, Ycoor1), Radius, , Start.Circle, End.Circle
		END IF
	     END IF
	  ELSE
	     IF Start.Set OR End.Set THEN
		ERROR 39
	     ELSE
		IF Color.Set THEN
		   IF Aspect.Set THEN
		      CIRCLE (Xcoor1, Ycoor1), Radius, Color.Code, , , Aspect
		   ELSE
		      CIRCLE (Xcoor1, Ycoor1), Radius, Color.Code
		   END IF
		ELSE
		   IF Aspect.Set THEN
		      CIRCLE (Xcoor1, Ycoor1), Radius, , , , Aspect
		   ELSE
		      CIRCLE (Xcoor1, Ycoor1), Radius
		   END IF
		END IF
	     END IF
	  END IF
          EXIT SUB
       END IF
    END IF
 END IF
 ERROR 39
END SUB

SUB Draw.Line.Step
 Allow.Extra = True
 Xcoor1 = False
 Xcoor1.Set = False
 Ycoor1 = False
 Ycoor1.Set = False
 Xcoor2 = False
 Xcoor2.Set = False
 Ycoor2 = False
 Ycoor2.Set = False
 Color.Code = False
 Color.Set = False
 Box.Set = False
 Filled.Set = False
 Style = False
 Style.Set = False
 Step.Set = False
 Out2 = MID$(Out2, 10)
 Out2 = STRIM$(Out2)
 Last.Token = False
 Out3 = Nul
 Token.Index = 1
 CALL Get.Token
 CALL Parse1(Temp3#)
 Xcoor1 = CINT(Temp3#)
 IF Last.Token THEN
    Xcoor1.Set = True
 END IF
 IF Strng = "," THEN
    Last.Token = False
    Out3 = Nul
    CALL Get.Token
    CALL Parse1(Temp3#)
    Ycoor1 = CINT(Temp3#)
    IF Last.Token THEN
       Ycoor1.Set = True
    END IF
    IF Strng = "," THEN
       Temp1$ = MID$(Out2, Token.Index)
       Temp1$ = STRIM$(Temp1$)
       Temp1$ = UCASE$(Temp1$)
       IF LEFT$(Temp1$, 4) = "STEP" THEN
	  Step.Set = True
	  Token.Index = Token.Index + 4
	  DO UNTIL MID$(Out2, Token.Index, 1) = " "
	     IF Token.Index > LEN(Out2) THEN
		EXIT DO
	     END IF
	     Token.Index = Token.Index + 1
	  LOOP
       END IF
       Last.Token = False
       Out3 = Nul
       CALL Get.Token
       CALL Parse1(Temp3#)
       Xcoor2 = CINT(Temp3#)
       IF Last.Token THEN
	  Xcoor2.Set = True
       END IF
       IF Strng = "," THEN
	  Last.Token = False
	  Out3 = Nul
	  CALL Get.Token
	  CALL Parse1(Temp3#)
	  Ycoor2 = CINT(Temp3#)
	  IF Last.Token THEN
	     Ycoor2.Set = True
	  END IF
	  IF Strng = "," THEN
	     Last.Token = False
	     Out3 = Nul
	     CALL Get.Token
	     CALL Parse1(Temp3#)
	     Color.Code = CINT(Temp3#)
	     IF Last.Token THEN
		Color.Set = True
	     END IF
	     IF Strng = "," THEN
		Temp1$ = MID$(Out2, Token.Index)
		Temp1$ = STRIM$(Temp1$)
		Temp1$ = UCASE$(Temp1$)
		IF LEFT$(Temp1$, 2) = "BF" OR LEFT$(Temp1$, 2) = "FB" THEN
		   Token.Index = Token.Index + 2
		   Box.Set = True
		   Filled.Set = True
		ELSE
		   IF LEFT$(Temp1$, 1) = "B" THEN
		      Token.Index = Token.Index + 1
		      Box.Set = True
		   ELSE
		      IF LEFT$(Temp1$, 1) = "F" THEN
			 Token.Index = Token.Index + 1
			 Filled.Set = True
		      END IF
		   END IF
		END IF
		IF Box.Set OR Filled.Set THEN
		   DO UNTIL MID$(Out2, Token.Index, 1) = " " OR MID$(Out2, Token.Index, 1) = ","
		      IF Token.Index > LEN(Out2) THEN
			 EXIT DO
		      END IF
		      Token.Index = Token.Index + 1
		   LOOP
		END IF
		CALL Get.Token
		CALL Parse1(Temp3#)
		IF Strng = "," THEN
		   Last.Token = False
		   Out3 = Nul
		   CALL Get.Token
		   CALL Parse1(Temp3#)
		   Style = CINT(Temp3#)
		   IF Last.Token THEN
		      Style.Set = True
		   END IF
		END IF
	     END IF
	  END IF
       END IF
    END IF
    IF Xcoor1.Set = False OR Ycoor1.Set = False THEN
       ERROR 28
    END IF
    IF Xcoor2.Set = False OR Ycoor2.Set = False THEN
       ERROR 28
    END IF
    IF Step.Set = False THEN
       IF Box.Set AND Filled.Set THEN
	  IF Color.Set AND Style.Set THEN
	     LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, BF, Style
	  ELSE
	     IF Color.Set THEN
		LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, BF
	     ELSE
		IF Style.Set THEN
		   LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , BF, Style
		ELSE
		   LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , BF
		END IF
	     END IF
	  END IF
       ELSE
	  IF Box.Set THEN
	     IF Color.Set AND Style.Set THEN
		LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, B, Style
	     ELSE
		IF Color.Set THEN
		   LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, B
		ELSE
		   IF Style.Set THEN
		      LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , B, Style
		   ELSE
		      LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , B
		   END IF
		END IF
	     END IF
	  ELSE
	     IF Filled.Set THEN
		ERROR 28
	     ELSE
		IF Color.Set AND Style.Set THEN
		   LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, , Style
		ELSE
		   IF Color.Set THEN
		      LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code
		   ELSE
		      IF Style.Set THEN
			 LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , , Style
		      ELSE
			 LINE STEP(Xcoor1, Ycoor1)-(Xcoor2, Ycoor2)
		      END IF
		   END IF
		END IF
	     END IF
	  END IF
       END IF
    ELSE
       IF Box.Set AND Filled.Set THEN
	  IF Color.Set AND Style.Set THEN
	     LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, BF, Style
	  ELSE
	     IF Color.Set THEN
		LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, BF
	     ELSE
		IF Style.Set THEN
		   LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , BF, Style
		ELSE
		   LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , BF
		END IF
	     END IF
	  END IF
       ELSE
	  IF Box.Set THEN
	     IF Color.Set AND Style.Set THEN
		LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, B, Style
	     ELSE
		IF Color.Set THEN
		   LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, B
		ELSE
		   IF Style.Set THEN
		      LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , B, Style
		   ELSE
		      LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , B
		   END IF
		END IF
	     END IF
	  ELSE
	     IF Filled.Set THEN
		ERROR 28
	     ELSE
		IF Color.Set AND Style.Set THEN
		   LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, , Style
		ELSE
		   IF Color.Set THEN
		      LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code
		   ELSE
		      IF Style.Set THEN
			 LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , , Style
		      ELSE
			 LINE STEP(Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2)
		      END IF
		   END IF
		END IF
	     END IF
	  END IF
       END IF
    END IF
    EXIT SUB
 END IF
 ERROR 28
END SUB

SUB Draw.Line
 Allow.Extra = True
 Xcoor1 = False
 Xcoor1.Set = False
 Ycoor1 = False
 Ycoor1.Set = False
 Xcoor2 = False
 Xcoor2.Set = False
 Ycoor2 = False
 Ycoor2.Set = False
 Color.Code = False
 Color.Set = False
 Box.Set = False
 Filled.Set = False
 Style = False
 Style.Set = False
 Step.Set = False
 Out2 = MID$(Out2, 5)
 Out2 = STRIM$(Out2)
 Last.Token = False
 Out3 = Nul
 Token.Index = 1
 CALL Get.Token
 CALL Parse1(Temp3#)
 Xcoor1 = CINT(Temp3#)
 IF Last.Token THEN
    Xcoor1.Set = True
 END IF
 IF Strng = "," THEN
    Last.Token = False
    Out3 = Nul
    CALL Get.Token
    CALL Parse1(Temp3#)
    Ycoor1 = CINT(Temp3#)
    IF Last.Token THEN
       Ycoor1.Set = True
    END IF
    IF Strng = "," THEN
       Temp1$ = MID$(Out2, Token.Index)
       Temp1$ = STRIM$(Temp1$)
       Temp1$ = UCASE$(Temp1$)
       IF LEFT$(Temp1$, 4) = "STEP" THEN
	  Step.Set = True
	  Token.Index = Token.Index + 4
	  DO UNTIL MID$(Out2, Token.Index, 1) = " "
	     IF Token.Index > LEN(Out2) THEN
		EXIT DO
	     END IF
	     Token.Index = Token.Index + 1
	  LOOP
       END IF
       Last.Token = False
       Out3 = Nul
       CALL Get.Token
       CALL Parse1(Temp3#)
       Xcoor2 = CINT(Temp3#)
       IF Last.Token THEN
	  Xcoor2.Set = True
       END IF
       IF Strng = "," THEN
	  Last.Token = False
	  Out3 = Nul
	  CALL Get.Token
	  CALL Parse1(Temp3#)
	  Ycoor2 = CINT(Temp3#)
	  IF Last.Token THEN
	     Ycoor2.Set = True
	  END IF
	  IF Strng = "," THEN
	     Last.Token = False
	     Out3 = Nul
	     CALL Get.Token
	     CALL Parse1(Temp3#)
	     Color.Code = CINT(Temp3#)
	     IF Last.Token THEN
		Color.Set = True
	     END IF
	     IF Strng = "," THEN
		Temp1$ = MID$(Out2, Token.Index)
		Temp1$ = STRIM$(Temp1$)
		Temp1$ = UCASE$(Temp1$)
		IF LEFT$(Temp1$, 2) = "BF" OR LEFT$(Temp1$, 2) = "FB" THEN
		   Token.Index = Token.Index + 2
		   Box.Set = True
		   Filled.Set = True
		ELSE
		   IF LEFT$(Temp1$, 1) = "B" THEN
		      Token.Index = Token.Index + 1
		      Box.Set = True
		   ELSE
		      IF LEFT$(Temp1$, 1) = "F" THEN
			 Token.Index = Token.Index + 1
			 Filled.Set = True
		      END IF
		   END IF
		END IF
		IF Box.Set OR Filled.Set THEN
		   DO UNTIL MID$(Out2, Token.Index, 1) = " " OR MID$(Out2, Token.Index, 1) = ","
		      IF Token.Index > LEN(Out2) THEN
			 EXIT DO
		      END IF
		      Token.Index = Token.Index + 1
		   LOOP
		END IF
		CALL Get.Token
		CALL Parse1(Temp3#)
		IF Strng = "," THEN
		   Last.Token = False
		   Out3 = Nul
		   CALL Get.Token
		   CALL Parse1(Temp3#)
		   Style = CINT(Temp3#)
		   IF Last.Token THEN
		      Style.Set = True
		   END IF
		END IF
	     END IF
	  END IF
       END IF
    END IF
    IF Xcoor2.Set = False OR Ycoor2.Set = False THEN
       ERROR 28
    END IF
    IF Step.Set = False THEN
       IF Xcoor1.Set AND Ycoor1.Set THEN
	  IF Box.Set AND Filled.Set THEN
	     IF Color.Set AND Style.Set THEN
		LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, BF, Style
	     ELSE
		IF Color.Set THEN
		   LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, BF
		ELSE
		   IF Style.Set THEN
		      LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , BF, Style
		   ELSE
		      LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , BF
		   END IF
		END IF
	     END IF
	  ELSE
	     IF Box.Set THEN
		IF Color.Set AND Style.Set THEN
		   LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, B, Style
		ELSE
		   IF Color.Set THEN
		      LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, B
		   ELSE
		      IF Style.Set THEN
			 LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , B, Style
		      ELSE
			 LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , B
		      END IF
		   END IF
		END IF
	     ELSE
		IF Filled.Set THEN
		   ERROR 28
		ELSE
		   IF Color.Set AND Style.Set THEN
		      LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code, , Style
		   ELSE
		      IF Color.Set THEN
			 LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), Color.Code
		      ELSE
			 IF Style.Set THEN
			    LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), , , Style
			 ELSE
			    LINE (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2)
			 END IF
		      END IF
		   END IF
		END IF
	     END IF
	  END IF
       ELSE
	  IF Box.Set AND Filled.Set THEN
	     IF Color.Set AND Style.Set THEN
		LINE -(Xcoor2, Ycoor2), Color.Code, BF, Style
	     ELSE
		IF Color.Set THEN
		   LINE -(Xcoor2, Ycoor2), Color.Code, BF
		ELSE
		   IF Style.Set THEN
		      LINE -(Xcoor2, Ycoor2), , BF, Style
		   ELSE
		      LINE -(Xcoor2, Ycoor2), , BF
		   END IF
		END IF
	     END IF
	  ELSE
	     IF Box.Set THEN
		IF Color.Set AND Style.Set THEN
		   LINE -(Xcoor2, Ycoor2), Color.Code, B, Style
		ELSE
		   IF Color.Set THEN
		      LINE -(Xcoor2, Ycoor2), Color.Code, B
		   ELSE
		      IF Style.Set THEN
			 LINE -(Xcoor2, Ycoor2), , B, Style
		      ELSE
			 LINE -(Xcoor2, Ycoor2), , B
		      END IF
		   END IF
		END IF
	     ELSE
		IF Filled.Set THEN
		   ERROR 28
		ELSE
		   IF Color.Set AND Style.Set THEN
		      LINE -(Xcoor2, Ycoor2), Color.Code, , Style
		   ELSE
		      IF Color.Set THEN
			 LINE -(Xcoor2, Ycoor2), Color.Code
		      ELSE
			 IF Style.Set THEN
			    LINE -(Xcoor2, Ycoor2), , , Style
			 ELSE
			    LINE -(Xcoor2, Ycoor2)
			 END IF
		      END IF
		   END IF
		END IF
	     END IF
	  END IF
       END IF
    ELSE
       IF Xcoor1.Set AND Ycoor1.Set THEN
	  IF Box.Set AND Filled.Set THEN
	     IF Color.Set AND Style.Set THEN
		LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, BF, Style
	     ELSE
		IF Color.Set THEN
		   LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, BF
		ELSE
		   IF Style.Set THEN
		      LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , BF, Style
		   ELSE
		      LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , BF
		   END IF
		END IF
	     END IF
	  ELSE
	     IF Box.Set THEN
		IF Color.Set AND Style.Set THEN
		   LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, B, Style
		ELSE
		   IF Color.Set THEN
		      LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, B
		   ELSE
		      IF Style.Set THEN
			 LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , B, Style
		      ELSE
			 LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , B
		      END IF
		   END IF
		END IF
	     ELSE
		IF Filled.Set THEN
		   ERROR 28
		ELSE
		   IF Color.Set AND Style.Set THEN
		      LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code, , Style
		   ELSE
		      IF Color.Set THEN
			 LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), Color.Code
		      ELSE
			 IF Style.Set THEN
			    LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2), , , Style
			 ELSE
			    LINE (Xcoor1, Ycoor1)-STEP(Xcoor2, Ycoor2)
			 END IF
		      END IF
		   END IF
		END IF
	     END IF
	  END IF
       ELSE
	  IF Box.Set AND Filled.Set THEN
	     IF Color.Set AND Style.Set THEN
		LINE -STEP(Xcoor2, Ycoor2), Color.Code, BF, Style
	     ELSE
		IF Color.Set THEN
		   LINE -STEP(Xcoor2, Ycoor2), Color.Code, BF
		ELSE
		   IF Style.Set THEN
		      LINE -STEP(Xcoor2, Ycoor2), , BF, Style
		   ELSE
		      LINE -STEP(Xcoor2, Ycoor2), , BF
		   END IF
		END IF
	     END IF
	  ELSE
	     IF Box.Set THEN
		IF Color.Set AND Style.Set THEN
		   LINE -STEP(Xcoor2, Ycoor2), Color.Code, B, Style
		ELSE
		   IF Color.Set THEN
		      LINE -STEP(Xcoor2, Ycoor2), Color.Code, B
		   ELSE
		      IF Style.Set THEN
			 LINE -STEP(Xcoor2, Ycoor2), , B, Style
		      ELSE
			 LINE -STEP(Xcoor2, Ycoor2), , B
		      END IF
		   END IF
		END IF
	     ELSE
		IF Filled.Set THEN
		   ERROR 28
		ELSE
		   IF Color.Set AND Style.Set THEN
		      LINE -STEP(Xcoor2, Ycoor2), Color.Code, , Style
		   ELSE
		      IF Color.Set THEN
			 LINE -STEP(Xcoor2, Ycoor2), Color.Code
		      ELSE
			 IF Style.Set THEN
			    LINE -STEP(Xcoor2, Ycoor2), , , Style
			 ELSE
			    LINE -STEP(Xcoor2, Ycoor2)
			 END IF
		      END IF
		   END IF
		END IF
	     END IF
	  END IF
       END IF
    END IF
    EXIT SUB
 END IF
 ERROR 28
END SUB

' writes out a user profiles record
Sub Write.User.Profile(Var2!)
 On Local Error Goto Write.User.Error
 Dim Locked As Integer
 Dim Lock.Count As Single
 Locked=False
 Lock.Count=Timeit!
 If Var2!<=0! Then
    Exit Sub
 Endif
Write.User.Resume1:
 If Share.Installed Then
    Lock SicFile,Var2!
    Locked=True
 Endif
Write.User.Resume2:
 Put SicFile,Var2!,UserProfile
 If Share.Installed Then
    Unlock SicFile,Var2!
 Endif
Write.User.Exit:
 Exit Sub
Write.User.Error:
 If Share.Installed Then
    If Err=70 Then
       Print "Write lock";Err
       If Time.Elapsed(Lock.Count,10!)=False Then
          If Locked=False Then
             Resume Write.User.Resume1
          Else
             Resume Write.User.Resume2
          Endif
       Endif
    Endif
 Endif
 Strng3 = "Write.User.Record write lock error:"+Str$(Err)+" : record"+Str$(Var2!)+"."
 Call IO.O
 Resume Write.User.Exit
End Sub

' reads in a user profile record
Sub Read.User.Record(Var2!)
 On Local Error Goto Read.User.Error
 Dim Lock.Count As Single
 Lock.Count=Timeit!
 If Var2!<=0! Then
    Exit Sub
 Endif
Read.User.Resume:
 Get SicFile,Var2!,UserProfile
Read.User.Exit:
 Exit Sub
Read.User.Error:
 If Share.Installed Then
    If Err=70 Then
       Print "Read lock";Err
       If Time.Elapsed(Lock.Count,10!)=False Then
          Resume Read.User.Resume
       Endif
    Endif
 Endif
 Strng3 = "Read.User.Record read lock error:"+Str$(Err)+" : record"+Str$(Var2!)+"."
 Call IO.O
 Resume Read.User.Exit
End Sub

' search account capabilities.
SUB Search.Limits(Var2$)
 On Local Error Goto Search.Error
 If Len(Var2$) Then
    Out9=Var2$
 Else
    No.Input.Out="all"
    Strng3 = "Command name or number(1-"+Ltrim$(Str$(MaxProfiles))+") or "+Quote+"all"+Quote+"? "
    CALL IO.I
 Endif
 X = Instr(Out9,",")
 If X Then
    Var = Int(Val(Left$(Out9,X-1))+.5)
    Var2 = Int(Val(Mid$(Out9,X+1))+.5)
 Else
    Var = Int(Val(Out9)+.5)
    Var2 = Var
 Endif
 If Var = 0 Then
    If Len(Out9) Then
       Out9=Ucase$(Out9) : Out9=Rtrim$(Ltrim$(Out9))
       If Out9="ALL" Or Out9="<ALL>" Or Out9=Quote$+"ALL"+Quote$ Then
          Var=1 : Var2=MaxProfiles
       Else
          For Temp1=1 To MaxProfiles
             If Rtrim$(Statements(Temp1))=Out9 Then
                Var=Temp1
                Exit For
             Endif
          Next
       Endif
    Endif
 Endif

 ' adjust values
 If Var2<Var Then Var2=Var
 If Var2>MaxProfiles Then Var2=MaxProfiles

 ' display limit searchs
 Call Modem.ANSI(4,33,14)
 Call ScreenANSI(4,33,14)
 If Var>=1 And Var<=MaxProfiles Then
    Strng3="Searching:"+Str$(Var)+" to"+Str$(Var2)+"."
    Call IO.O
    VarZ=1
    Allow.Break=True
    Break=False
    Continuous=False
    Graphics.Off=True
    For VarX=Var To Var2
       Temp$=Rtrim$(Statements(VarX))
       Temp$=Ltrim$(Str$(VarX))+". "+Temp$
       If UserProfile.Commands(VarX)=True Then
          Strng3=Temp$+": enabled."
       Else
          If UserProfile.Commands(VarX)=False Then
             Strng3=Temp$+": disabled."
          Else
             Strng3=Temp$+": (error)."
          Endif
       Endif
       Call Modem.ANSI(4,33,14)
       Call ScreenANSI(4,33,14)
       Call IO.O
       VarZ=VarZ+1
       If Break Then
          Exit For
       Endif
       If VarZ>=User.Pagelength-2 Then
          VarZ=False
          If Continuous=False Then
             Strng2 = "More(y/n/c/q)"
             CALL More.Prompt(Strng2, "yncq", Output.Char$, "y")
             If Output.Char$ = "c" THEN
                Continuous=True
             Endif
             If Output.Char$ = "n" THEN
                Exit For
             Endif
             If Output.Char$ = "q" THEN
                Exit For
             Endif
          Endif
       Endif
    Next
    Allow.Break=False
    If VarZ Then
       Strng2 = "More(y/n)"
       CALL More.Prompt(Strng2, "yn", Output.Char$, "y")
    Endif
 Else
    Strng3="Command not found."
    Call IO.O
 Endif
 Exit Sub
Search.Resume:
 Exit Sub
Search.Error:
 Resume Search.Resume
END SUB

' display account capabilities.
SUB Display.Limits
 On Local Error Goto Search.Error2
 Var$ = Nul
 FOR Var1 = 1 TO MaxProfiles
    IF UserProfile.Commands(Var1) THEN
       Var$ = Var$ + "1"
    ELSE
       Var$ = Var$ + "0"
    END IF
 NEXT
 DO
    Var2$ = LEFT$(Var$, 4)
    Var$ = MID$(Var$, 5)
    IF LEN(Var2$) < 4 THEN
       Var2$ = Var2$ + STRING$(4 - LEN(Var2$), "1")
    END IF
    Var = False
    IF MID$(Var2$, 4, 1) = "1" THEN
       Var = Var + 1
    END IF
    IF MID$(Var2$, 3, 1) = "1" THEN
       Var = Var + 2
    END IF
    IF MID$(Var2$, 2, 1) = "1" THEN
       Var = Var + 4
    END IF
    IF MID$(Var2$, 1, 1) = "1" THEN
       Var = Var + 8
    END IF
    Var3$ = Var3$ + HEX$(Var)
    IF Var$ = Nul THEN
       EXIT DO
    END IF
 LOOP
 Call Modem.ANSI(4,37,15)
 Call ScreenANSI(4,37,15)
 Strng3 = "Account limits value:"
 CALL IO.O
 Call Modem.ANSI(4,33,14)
 Call ScreenANSI(4,33,14)
 Strng3 = Var3$
 CALL IO.O
 Call Modem.ANSI(4,37,15)
 Call ScreenANSI(4,37,15)
 Strng3="Display account limits values(y/n)?"
 CALL IO.I
 IF Yes THEN CALL Search.Limits("ALL")
 Exit Sub
Search.Resume2:
 Exit Sub
Search.Error2:
 Resume Search.Resume2
END SUB

Rem TRIANGLE <x1>,<y1>,<x2>,<y2>,<x3>,<y3>,<color>
Sub DrawTriangle
   Allow.Extra = True
   Xcoor1 = False
   Ycoor1 = False
   Xcoor2 = False
   Ycoor2 = False
   Xcoor3 = False
   Ycoor3 = False
   ColorCode = False
   Out2 = Mid$(Out2, 9)
   Out2 = XTRIM$(Out2, False)
   Out2 = UCase$(Out2)
   Last.Token = False
   Out3 = Nul
   Token.Index = 1
   Call Get.Token
   Call Parse1(Temp3#)
   Xcoor1 = CInt(Temp3#)
   If Last.Token = 3 Then
      Error 168
   End If
   If Strng = "," Then
      Last.Token = False
      Out3 = Nul
      Call Get.Token
      Call Parse1(Temp3#)
      Ycoor1 = CInt(Temp3#)
      If Last.Token = 3 Then
         Error 168
      End If
      If Strng = "," Then
         Last.Token = False
         Out3 = Nul
         Call Get.Token
         Call Parse1(Temp3#)
         Xcoor2 = CInt(Temp3#)
         If Last.Token = 3 Then
            Error 168
         End If
         If Strng = "," Then
            Last.Token = False
            Out3 = Nul
            Call Get.Token
            Call Parse1(Temp3#)
            Ycoor2 = CInt(Temp3#)
            If Last.Token = 3 Then
               Error 168
            End If
            If Strng = "," Then
               Last.Token = False
               Out3 = Nul
               Call Get.Token
               Call Parse1(Temp3#)
               Xcoor3 = CInt(Temp3#)
               If Last.Token = 3 Then
                  Error 168
               End If
               If Strng = "," Then
                  Last.Token = False
                  Out3 = Nul
                  Call Get.Token
                  Call Parse1(Temp3#)
                  Ycoor3 = CInt(Temp3#)
                  If Last.Token = 3 Then
                     Error 168
                  End If
                  If Strng = "," Then
                     Last.Token = False
                     Out3 = Nul
                     Call Get.Token
                     Call Parse1(Temp3#)
                     ColorCode = CInt(Temp3#)
                     If Last.Token = 3 Then
                        Error 168
                     End If
                     If Strng <> Nul Then
                        Error 168
                     End If
                     ' make triangle
                     Line (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), ColorCode
                     Line (Xcoor2, Ycoor2)-(Xcoor3, Ycoor3), ColorCode
                     Line (Xcoor3, Ycoor3)-(Xcoor1, Ycoor1), ColorCode
                     Exit Sub
                  End If
               End If
            End If
         End If
      End If
   End If
   Error 168
End Sub

Rem SQUARE <x1>,<y1>,<x2>,<y2>,<x3>,<y3>,<x4>,<y4>,<color>
Sub DrawSquare
   Allow.Extra = True
   Xcoor1 = False
   Ycoor1 = False
   Xcoor2 = False
   Ycoor2 = False
   Xcoor3 = False
   Ycoor3 = False
   Xcoor4 = False
   Ycoor4 = False
   ColorCode = False
   Out2 = Mid$(Out2, 7)
   Out2 = XTRIM$(Out2, False)
   Out2 = UCase$(Out2)
   Last.Token = False
   Out3 = Nul
   Token.Index = 1
   Call Get.Token
   Call Parse1(Temp3#)
   Xcoor1 = CInt(Temp3#)
   If Last.Token = 3 Then
      Error 171
   End If
   If Strng = "," Then
      Last.Token = False
      Out3 = Nul
      Call Get.Token
      Call Parse1(Temp3#)
      Ycoor1 = CInt(Temp3#)
      If Last.Token = 3 Then
         Error 171
      End If
      If Strng = "," Then
         Last.Token = False
         Out3 = Nul
         Call Get.Token
         Call Parse1(Temp3#)
         Xcoor2 = CInt(Temp3#)
         If Last.Token = 3 Then
            Error 171
         End If
         If Strng = "," Then
            Last.Token = False
            Out3 = Nul
            Call Get.Token
            Call Parse1(Temp3#)
            Ycoor2 = CInt(Temp3#)
            If Last.Token = 3 Then
               Error 171
            End If
            If Strng = "," Then
               Last.Token = False
               Out3 = Nul
               Call Get.Token
               Call Parse1(Temp3#)
               Xcoor3 = CInt(Temp3#)
               If Last.Token = 3 Then
                  Error 171
               End If
               If Strng = "," Then
                  Last.Token = False
                  Out3 = Nul
                  Call Get.Token
                  Call Parse1(Temp3#)
                  Ycoor3 = CInt(Temp3#)
                  If Last.Token = 3 Then
                     Error 171
                  End If
                  If Strng = "," Then
                     Last.Token = False
                     Out3 = Nul
                     Call Get.Token
                     Call Parse1(Temp3#)
                     Xcoor4 = CInt(Temp3#)
                     If Last.Token = 3 Then
                        Error 171
                     End If
                     If Strng = "," Then
                        Last.Token = False
                        Out3 = Nul
                        Call Get.Token
                        Call Parse1(Temp3#)
                        Ycoor4 = CInt(Temp3#)
                        If Last.Token = 3 Then
                           Error 171
                        End If
                        If Strng = "," Then
                           Last.Token = False
                           Out3 = Nul
                           Call Get.Token
                           Call Parse1(Temp3#)
                           ColorCode = CInt(Temp3#)
                           If Last.Token = 3 Then
                              Error 171
                           End If
                           If Strng <> Nul Then
                              Error 171
                           End If
                           ' make square
                           Line (Xcoor1, Ycoor1)-(Xcoor2, Ycoor2), ColorCode
                           Line (Xcoor2, Ycoor2)-(Xcoor3, Ycoor3), ColorCode
                           Line (Xcoor3, Ycoor3)-(Xcoor4, Ycoor4), ColorCode
                           Line (Xcoor4, Ycoor4)-(Xcoor1, Ycoor1), ColorCode
                           Exit Sub
                        End If
                     End If
                  End If
               End If
            End If
         End If
      End If
   End If
   Error 171
End Sub

Rem DrawPolygon <x1>,<y1>,<r>,<n>,<a>,<c>
Sub DrawPolygon
   Allow.Extra = True
   Out2 = Mid$(Out2, 8)
   Out2 = XTRIM$(Out2, False)
   Out2 = UCase$(Out2)
   Last.Token = False
   Out3 = Nul
   Token.Index = 1
   Call Get.Token
   Call Parse1(Temp3#)
   xc = CInt(Temp3#)
   If Last.Token = 3 Then
      Error 169
   End If
   If Strng = "," Then
      Last.Token = False
      Out3 = Nul
      Call Get.Token
      Call Parse1(Temp3#)
      yc = CInt(Temp3#)
      If Last.Token = 3 Then
         Error 169
      End If
      If Strng = "," Then
         Last.Token = False
         Out3 = Nul
         Call Get.Token
         Call Parse1(Temp3#)
         r = CInt(Temp3#)
         If Last.Token = 3 Then
            Error 169
         End If
         If Strng = "," Then
            Last.Token = False
            Out3 = Nul
            Call Get.Token
            Call Parse1(Temp3#)
            n = CInt(Temp3#)
            If Last.Token = 3 Then
               Error 169
            End If
            If Strng = "," Then
               Last.Token = False
               Out3 = Nul
               Call Get.Token
               Call Parse1(Temp3#)
               a = CInt(Temp3#)
               If Last.Token = 3 Then
                  Error 169
               End If
               If Strng = "," Then
                  Last.Token = False
                  Out3 = Nul
                  Call Get.Token
                  Call Parse1(Temp3#)
                  c = CInt(Temp3#)
                  If Last.Token = 3 Then
                     Error 169
                  End If
                  If Strng <> Nul Then
                     Error 169
                  End If
                  ' make polygon
                  If n >= 3 And n <= 30 Then
                     x1 = xc + r * Cos(PI2# * a)
                     y1 = yc + r * Sin(PI2# * a)
                     Line (x1, y1)-(x1, y1), c
                     For i = 0 To n
                        a = a + 180 / n
                        x1 = xc + r * Cos(PI2# * a)
                        y1 = yc + r * Sin(PI2# * a)
                        Line Step(0, 0)-(x1, y1), c
                     Next
                     Exit Sub
                  End If
               End If
            End If
         End If
      End If
   End If
   Error 169
End Sub

Sub LockFile ' lock
   Out2 = Mid$(Out2, 5)
   Out2 = STRIM$(Out2)
   If Left$(Out2,1) = "#" Then
      Out2=Mid$(Out2,2)
   Endif
   Out2=Ltrim$(Out2)
   Token.Index = 1
   Call Get.Token
   Call Parse1(Temp4#)
   File.Num = CInt(Temp4#)
   If File.Num <= 0% Or File.Num > MaxFiles Then
      Error 52
      Exit Sub
   End If
   If File.Trap(File.Num) Then
      Break = -2
      Exit Sub
   End If
   If Strng = "," Or Strng = ";" Then
      Call Get.Token
      Call Parse1(Temp4#)
      Filerec& = CInt(Temp4#)
      If Strng = "," Or Strng = ";" Or Strng = "TO" Then
         Call Get.Token
         Call Parse1(Temp4#)
         Filerec2& = CInt(Temp4#)
         Lock File.Num, Filerec& To Filerec2&
         For Z = 1 To RecordCount
            If File.Records(Z) > 0& Then
               If File.Records(Z) = Filerec& Then
                  Record.Number=Filerec&
                  Break = -3
                  Exit Sub
               End If
            End If
         Next
         For Z = 1 To RecordCount
            If File.Records(Z) > 0& Then
               If File.Records(Z) = Filerec2& Then
                  Record.Number=Filerec2&
                  Break = -3
                  Exit Sub
               End If
            End If
         Next
      Else
         Lock File.Num, Filerec&
         For Z = 1 To RecordCount
            If File.Records(Z) > 0& Then
               If File.Records(Z) = Filerec& Then
                  Record.Number=Filerec&
                  Break = -3
                  Exit Sub
               End If
            End If
         Next
      End If
      Exit Sub
   End If
   Lock File.Num
End Sub

Sub UnlockFile ' unlock
   Out2 = Mid$(Out2, 7)
   Out2 = STRIM$(Out2)
   If Left$(Out2,1) = "#" Then
      Out2=Mid$(Out2,2)
   Endif
   Out2=Ltrim$(Out2)
   Token.Index = 1
   Call Get.Token
   Call Parse1(Temp4#)
   File.Num = CInt(Temp4#)
   If File.Num <= 0% Or File.Num > MaxFiles Then
      Error 52
      Exit Sub
   End If
   If File.Trap(File.Num) Then
      Break = -2
      Exit Sub
   End If
   If Strng = "," Or Strng = ";" Then
      Call Get.Token
      Call Parse1(Temp4#)
      Filerec& = CInt(Temp4#)
      If Strng = "," Or Strng = ";" Or Strng = "TO" Then
         Call Get.Token
         Call Parse1(Temp4#)
         Filerec2& = CInt(Temp4#)
         Unlock File.Num, Filerec& To Filerec2&
         For Z = 1 To RecordCount
            If File.Records(Z) > 0& Then
               If File.Records(Z) = Filerec& Then
                  Record.Number=Filerec&
                  Break = -3
                  Exit Sub
               End If
            End If
         Next
         For Z = 1 To RecordCount
            If File.Records(Z) > 0& Then
               If File.Records(Z) = Filerec2& Then
                  Record.Number=Filerec2&
                  Break = -3
                  Exit Sub
               End If
            End If
         Next
      Else
         Unlock File.Num, Filerec&
         For Z = 1 To RecordCount
            If File.Records(Z) > 0& Then
               If File.Records(Z) = Filerec& Then
                  Record.Number=Filerec&
                  Break = -3
                  Exit Sub
               End If
            End If
         Next
      End If
      Exit Sub
   End If
   Unlock File.Num
End Sub

