 Rem File: Cmd200.bas
 Rem Sub: QuickEdit
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 200 -- QuickEdit."
    Color 7,0
    End
 Endif
 Call QuickEdit
Main.Resume:
 Chained=-2
 Shell.Type2=-1
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub QuickEdit
 On Local Error Goto Error.Trap1xx
 Redim Temp.Array1(30 To 37) As Integer ' foreground ansi colors
 Redim Temp.Array2(40 To 47) As Integer ' background ansi colors
 Gosub Get.Config

 VarX$=Ucase$(Environ$("BLIND"))
 If VarX$="ON" Or VarX$="-1" Or VarX$="TRUE" Then
    Border.Off=-1
 Endif

 VarX$=Ucase$(Environ$("BLINDCHAR"))
 If VarX$="ON" Or VarX$="-1" Or VarX$="TRUE" Then
    Border.Char=-1
 Endif

 Next.Room=SFalse
 GOSUB MakeBox
 GOSUB FillBox
 Position = 1
 DO
    GOSUB GetKeyStroke
    IF Var1 = 3 THEN ' ctrl-c
       X$ = INKEY$
       EXIT DO
    END IF
    IF Var1 = 27 THEN ' escape
       X$ = INKEY$
       EXIT DO
    END IF
    IF Var1=9 THEN ' tab
       Var1=False
       Var2=77
    END IF
    SELECT CASE Var1
    CASE 0
       SELECT CASE Var2
       Case 79, 81, 117 ' end/pagedn
          IF Position <> 15 THEN
             Call ANSI2(4, 37, 44)
             GOSUB DisplayTitle
             Position = 15
             Call ANSI2(1, 34, 46)
             GOSUB DisplayTitle
          END IF
       Case 71, 73, 119 ' home/pageup
          IF Position <> 1 THEN
             Call ANSI2(4, 37, 44)
             GOSUB DisplayTitle
             Position = 1
             Call ANSI2(1, 34, 46)
             GOSUB DisplayTitle
          END IF
       CASE 77, 72, 116, 157, 141, 132, 152 ' right/up
          IF Position < 15 THEN
             Call ANSI2(4, 37, 44)
             GOSUB DisplayTitle
             Position = Position + 1
             Call ANSI2(1, 34, 46)
             GOSUB DisplayTitle
          END IF
       CASE 15, 75, 80, 115, 155, 145, 118, 160 ' shift-tab/left/down
          IF Position > 1 THEN
             Call ANSI2(4, 37, 44)
             GOSUB DisplayTitle
             Position = Position - 1
             Call ANSI2(1, 34, 46)
             GOSUB DisplayTitle
          END IF
       END SELECT
    Case 24 ' ctrl-x
       Border.Off=0
       Border.Char=not Border.Char
       GOSUB MakeBox
       GOSUB FillBox
       Position = 1
    Case 25 ' ctrl-y
       Border.Off=not Border.Off
       Border.Char=0
       GOSUB MakeBox
       GOSUB FillBox
       Position = 1
    CASE 1 ' ctrl-a
       Var=Temp.Array1(37)
       For V2=37 To 31 Step -1
          Temp.Array1(V2)=Temp.Array1(V2-1)
       Next
       Temp.Array1(30)=Var
       GOSUB MakeBox
       GOSUB FillBox
       Position = 1
    CASE 2 ' ctrl-b
       Var=Temp.Array2(47)
       For V2=47 To 41 Step -1
          Temp.Array2(V2)=Temp.Array2(V2-1)
       Next
       Temp.Array2(40)=Var
       GOSUB MakeBox
       GOSUB FillBox
       Position = 1
    CASE 13 ' enter
       IF Position > 1 THEN
          RESTORE EditData
          FOR V = 1 TO Position
             READ Xcoor, Ycoor, Line.Length
          NEXT
          V = Position
          Call ANSI2(4, 30, 47)
          GOSUB DisplayData
          Row = Xcoor
          Column = Ycoor
          Strng3 = S$
          CALL ScreenEdit
          SELECT CASE Position
          CASE 2
             Var!=Int(Val(Strng3)+.5)
             If Var!>SFalse And Var!<=32767! Then
                UserRecord.Level=Csng(Var!)
                Call New.Stats
             Endif
          CASE 3
             If Rtrim$(Strng3)<>Nul Then
                UserRecord.ClassName=Strng3
             Endif
          Case 4 To 10
             Var!=Int(Val(Strng3)+.5)
             If Var!>SFalse And Var!<=32767! Then
                UserRecord.Stats(Position-3)=Csng(Var!)
             Endif
          Case 11 To 14
             Var!=Int(Val(Strng3)+.5)
             If Var!>SFalse And Var!<=100! Then
                UserRecord.Weapons(Position-10)=Csng(Var!)
             Endif
          Case 15
             Var!=Int(Val(Strng3)+.5)
             If Var!>SFalse And Var!<=Lof(RoomFile)/RoomRecLen Then
                If Var!=Room Then
                   Next.Room=SFalse
                Endif
                If Var!<>Room Then
                   Next.Room=Var!
                Endif
             Endif
          End Select
          Call ANSI2(4, 37, 44)
          GOSUB DisplayData
          Call ANSI2(1, 34, 46)
          GOSUB DisplayTitle
       END IF
    END SELECT
 LOOP
 EXIT SUB

GetKeyStroke:
 Var1 = 0
 Var2 = 0
 DO
    V$ = Inkey$
    Select Case Len(V$)
    Case 1
       Var1 = Asc(V$)
       Return
    Case 2
       Var2 = Asc(Right$(V$, 1))
       Return
    End Select
 LOOP
 EXIT SUB

MakeBox:
 Call ANSI2(4, 33, 44)
 Call ANSI2(2, 1, 1)
 If Border.Off=False Then
    If Border.Char=0 Then
       Strng = " " + CHR$(201) + STRING$(76, 205) + CHR$(187) + " "
    Else
       Strng = " +" + STRING$(76, "-") + "+ "
    Endif
 Else
    Strng = String$(80, 32)
 Endif
 Call Scrn2(Strng)
 If Border.Off=False Then
    If Border.Char=0 Then
       Strng = " " + CHR$(186) + SPACE$(76) + CHR$(186) + " "
    Else
       Strng = " |" + SPACE$(76) + "| "
    Endif
 Else
    Strng=String$(80, 32)
 Endif
 Call ANSI2(2, 2, 1)
 Call Scrn2(Strng)
 Call ANSI2(2, 3, 1)
 Call Scrn2(Strng)
 Call ANSI2(2, 4, 1)
 Call Scrn2(Strng)
 Call ANSI2(2, 5, 1)
 If Border.Off=False Then
    If Border.Char=0 Then
       Strng = " " + CHR$(200) + STRING$(76, 205) + CHR$(188) + " "
    Else
       Strng = " +" + STRING$(76, "-") + "+ "
    Endif
 Else
    Strng = String$(80, 32)
 Endif
 Call Scrn2(Strng)
 RETURN

FillBox:
 Call ANSI2(4, 35, 44)
 Call ANSI2(2, 2, 3)
 Strng = "QuickEdit:"
 Call Scrn2(Strng)
 ' make titles.
 Call ANSI2(4, 37, 44)
 RESTORE TitleData
 FOR V = 1 TO 15
    IF V = 1 THEN
       Call ANSI2(1, 34, 46)
    ELSE
       Call ANSI2(4, 37, 44)
    END IF
    READ x, y, S$
    Call ANSI2(2, x, y)
    Strng = S$
    Call Scrn2(Strng)
 NEXT
 Call ANSI2(4, 37, 44)
 Call ANSI2(2, 4, 3)
 Strng = "Weapons:"
 Call Scrn2(Strng)
 ' display edit fields.
 Call ANSI2(4, 37, 44)
 FOR V = 1 TO 15
    GOSUB DisplayData
 NEXT
 ' make first title.
 Call ANSI2(4, 37, 44)
 RESTORE TitleData
 Call ANSI2(1, 34, 46)
 READ x, y, S$
 Call ANSI2(2, x, y)
 Strng = S$
 Call Scrn2(Strng)
 RETURN

DisplayTitle:
 RESTORE TitleData
 FOR V = 1 TO Position
    READ x, y, S$
 NEXT
 Call ANSI2(2, x, y)
 Strng = S$
 Call Scrn2(Strng)
 RETURN

DisplayData:
 SELECT CASE V
 CASE 1
    Call ANSI2(2, 2, 26)
    Strng = SPACE$(8)
    Call Scrn2(Strng)
    Call ANSI2(2, 2, 26)
    S$ = MID$(STR$(User.Index), 2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 2
    Call ANSI2(2, 2, 42)
    Strng = SPACE$(5)
    Call Scrn2(Strng)
    Call ANSI2(2, 2, 42)
    S$ = MID$(STR$(UserRecord.Level), 2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 3
    Call ANSI2(2, 2, 59)
    Strng = SPACE$(20)
    Call Scrn2(Strng)
    Call ANSI2(2, 2, 59)
    S$ = UserRecord.ClassName
    Strng = S$
    Call Scrn2(Strng)
 CASE 4
    Call ANSI2(2, 3, 8)
    Strng = SPACE$(5)
    Call Scrn2(Strng)
    Call ANSI2(2, 3, 8)
    S$ = MID$(STR$(UserRecord.Stats(1)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 5
    Call ANSI2(2, 3, 19)
    Strng = SPACE$(5)
    Call Scrn2(Strng)
    Call ANSI2(2, 3, 19)
    S$ = MID$(STR$(UserRecord.Stats(2)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 6
    Call ANSI2(2, 3, 30)
    Strng = SPACE$(5)
    Call Scrn2(Strng)
    Call ANSI2(2, 3, 30)
    S$ = MID$(STR$(UserRecord.Stats(3)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 7
    Call ANSI2(2, 3, 41)
    Strng = SPACE$(5)
    Call Scrn2(Strng)
    Call ANSI2(2, 3, 41)
    S$ = MID$(STR$(UserRecord.Stats(4)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 8
    Call ANSI2(2, 3, 52)
    Strng = SPACE$(5)
    Call Scrn2(Strng)
    Call ANSI2(2, 3, 52)
    S$ = MID$(STR$(UserRecord.Stats(5)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 9
    Call ANSI2(2, 3, 63)
    Strng = SPACE$(5)
    Call Scrn2(Strng)
    Call ANSI2(2, 3, 63)
    S$ = MID$(STR$(UserRecord.Stats(6)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 10
    Call ANSI2(2, 3, 74)
    Strng = SPACE$(5)
    Call Scrn2(Strng)
    Call ANSI2(2, 3, 74)
    S$ = MID$(STR$(UserRecord.Stats(7)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 11
    Call ANSI2(2, 4, 19)
    Strng = SPACE$(3)
    Call Scrn2(Strng)
    Call ANSI2(2, 4, 19)
    S$ = MID$(STR$(UserRecord.Weapons(1)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 12
    Call ANSI2(2, 4, 29)
    Strng = SPACE$(3)
    Call Scrn2(Strng)
    Call ANSI2(2, 4, 29)
    S$ = MID$(STR$(UserRecord.Weapons(2)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 13
    Call ANSI2(2, 4, 40)
    Strng = SPACE$(3)
    Call Scrn2(Strng)
    Call ANSI2(2, 4, 40)
    S$ = MID$(STR$(UserRecord.Weapons(3)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 14
    Call ANSI2(2, 4, 55)
    Strng = SPACE$(3)
    Call Scrn2(Strng)
    Call ANSI2(2, 4, 55)
    S$ = MID$(STR$(UserRecord.Weapons(4)),2)
    Strng = S$
    Call Scrn2(Strng)
 CASE 15
    Call ANSI2(2, 4, 65)
    Strng = SPACE$(8)
    Call Scrn2(Strng)
    Call ANSI2(2, 4, 65)
    If Next.Room Then
       S$ = MID$(STR$(Next.Room), 2)
    Else
       S$ = MID$(STR$(Room), 2)
    Endif
    Strng = S$
    Call Scrn2(Strng)
 END SELECT
 RETURN

Get.Config:
 ' foreground ansi colors
 For VarX=30 To 37
    Temp.Array1(VarX)=VarX
 Next

 ' background ansi colors
 For VarX=40 To 47
    Temp.Array2(VarX)=VarX
 Next

 ' get config settings
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD200]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Goto Next.Read
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Goto Next.Read
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             VarZ=Int(Val(Var3$)+.5)
             Gosub Parse.Options
          Endif
       Loop
    Endif
 Loop
 Return
Next.Read:
 Close #TempFile1
 Filename$=DND.Path+"CMD200.CFG"
 If Dir$(Filename$)="" Then
    Return
 Endif
 Open Filename$ For Input As #TempFile1
 Do
    If Eof(TempFile1) Then
       Exit Do
    Endif
    Line Input #TempFile1, Var$
    Var$=Ltrim$(Rtrim$(Var$))
    If Left$(Var$,1)<>";" Then
       VarX$=UserRecord.CodeName
       VarX$=Rtrim$(VarX$)
       VarX$=Ucase$(VarX$)
       If Ucase$(Var$)="["+VarX$+"]" Then
          VarZ=0
          ' foreground ansi colors
          For VarX=30 To 37
             Temp.Array1(VarX)=VarX
          Next

          ' background ansi colors
          For VarX=40 To 47
             Temp.Array2(VarX)=VarX
          Next

          Do
             If Eof(TempFile1) Then
                Exit Do
             Endif
             Line Input #TempFile1, Var$
             If Ucase$(Var$)="[END]" Then
                Return
             Endif
             Var=Instr(Var$,"=")
             If Var Then
                Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
                Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
                VarZ=Int(Val(Var3$)+.5)
                Gosub Parse.Options
             Endif
          Loop
       Endif
    Endif
 Loop
 Return
Parse.Options:
 Select Case Left$(Lcase$(Var2$), 10)
 Case "blind"
    Select Case Lcase$(Var3$)
    Case "on", "-1", "true" 
       Border.Off=-1
       Border2.Off=-1
    End Select
 Case "blindchar"
    Select Case Lcase$(Var3$)
    Case "on", "-1", "true" 
       Border.Char=-1
       Border2.Char=-1
    End Select
 Case "foreground"
    VarQ=Int(Val(Mid$(Var2$,11))+.5)
    If VarQ>=1 And VarQ<=8 Then
       If VarZ>=30 And VarZ<=37 Then
          Temp.Array1(VarQ+29)=VarZ
       Endif
    Endif
 Case "background"
    VarQ=Int(Val(Mid$(Var2$,11))+.5)
    If VarQ>=1 And VarQ<=8 Then
       If VarZ>=40 And VarZ<=47 Then
          Temp.Array2(VarQ+39)=VarZ
       Endif
    Endif
 End Select
 Return
Error.Resume1xx:
 Exit Sub
Error.Trap1xx:
 Resume Error.Resume1xx
End Sub

TitleData:
 DATA 2, 14,"User Index:"
 DATA 2, 35, "Level:"
 DATA 2, 48, "Classname:"
 DATA 3, 3, "Str:"
 DATA 3, 14, "Int:"
 DATA 3, 25, "Wis:"
 DATA 3, 36, "Dex:"
 DATA 3, 47, "Con:"
 DATA 3, 58, "Pie:"
 DATA 3, 69, "Cha:"
 DATA 4, 12, "Blunt:"
 DATA 4, 23, "Pole:"
 DATA 4, 33, "Sharp:"
 DATA 4, 44, "Thrusting:"
 DATA 4, 59, "Room:"

EditData:
 DATA 1, 1, 1
 DATA 2, 42, 5
 DATA 2, 59, 20
 DATA 3, 8, 5
 DATA 3, 19, 5
 DATA 3, 30, 5
 DATA 3, 41, 5
 DATA 3, 52, 5
 DATA 3, 63, 5
 DATA 3, 74, 5
 DATA 4, 19, 3
 DATA 4, 29, 3
 DATA 4, 40, 3
 DATA 4, 55, 3
 DATA 4, 65, 8

SUB ScreenEdit
 ON LOCAL ERROR GOTO Error.Trap47
 Strng3 = RTRIM$(Strng3)
 Inserting = True
 CALL ANSI2(4, 37, 44)
 CALL ANSI2(2, 4, 75)
 Strng = "Ins"
 CALL Scrn2(Strng)
 CALL ANSI2(4, 37, 40)
 CALL ANSI2(2, Xcoor, Ycoor)
 Locate Xcoor, Ycoor, 1
 CALL Scrn2(Strng3)
 Ycoor = Ycoor + LEN(Strng3)
 DO
    CALL ANSI2(2, Xcoor, Ycoor)
    IF Inserting = -2 THEN
       Locate Xcoor, Ycoor, 1, 1, 7
    ELSE
       IF Inserting = -1 THEN
          Locate Xcoor, Ycoor, 1, 3, 7
       ELSE
          Locate Xcoor, Ycoor, 1, 7, 7
       END IF
    END IF
    TempX$ = Nul
    DO WHILE TempX$ = Nul
       TempX$ = Inkey$
    LOOP
    SELECT CASE LEN(TempX$)
    CASE 1
       SELECT CASE TempX$
       CASE CHR$(13), CHR$(27) ' exit
          EXIT DO
       CASE CHR$(8) ' backspace
          IF Ycoor - Column > False THEN
             IF Inserting = False THEN
                Ycoor = Ycoor - 1
             ELSE
                Strng3 = LEFT$(Strng3, Ycoor - Column - 1) + MID$(Strng3, Ycoor - Column + 1)
                Ycoor = Ycoor - 1
                CALL ANSI2(2, Xcoor, Ycoor)
                Strng = MID$(Strng3, Ycoor - Column + 1) + " "
                CALL Scrn2(Strng)
             END IF
          END IF
       CASE CHR$(9) ' tab
          IF Ycoor - Column + 8 <= LEN(Strng3) THEN
             Ycoor = Ycoor + 8
          ELSE
             Ycoor = LEN(Strng3) + Column
          END IF
       CASE ELSE ' insert character
          IF ASC(TempX$) >= 32 AND ASC(TempX$) <= 127 THEN
             If Ycoor - Column + 1 <= Line.Length Then
                IF Inserting = False THEN
                   IF Ycoor - Column + 1 > LEN(Strng3) THEN
                      Strng3 = Strng3 + TempX$
                   ELSE
                      MID$(Strng3, Ycoor - Column + 1, 1) = TempX$
                   END IF
                   Strng = TempX$
                   CALL Scrn2(Strng)
                   Ycoor = Ycoor + 1
                ELSE
                   Strng3 = LEFT$(Strng3, Ycoor - Column) + TempX$ + MID$(Strng3, Ycoor - Column + 1)
                   Strng3 = LEFT$(Strng3, Line.Length)
                   CALL ANSI2(2, Xcoor, Ycoor)
                   Strng = MID$(Strng3, Ycoor - Column + 1)
                   CALL Scrn2(Strng)
                   Ycoor = Ycoor + 1
                Endif
             END IF
          END IF
       END SELECT
    CASE 2
       Temp = ASC(MID$(TempX$, 2, 1))
       SELECT CASE Temp
       CASE 82 ' insert
          Select Case Inserting
          Case 0
             Inserting=-1
          Case -1
             Inserting=-2
          Case -2
             Inserting=0
          End Select
          'Inserting = NOT Inserting
          CALL ANSI2(4, 37, 44)
          CALL ANSI2(2, 4, 75)
          IF Inserting = False THEN
             Strng = SPACE$(3)
          ELSE
             Strng = "Ins"
          END IF
          CALL Scrn2(Strng)
          CALL ANSI2(4, 37, 40)
       CASE 83, 147 ' delete/control-delete
          IF Ycoor - Column + 1 <= LEN(Strng3) THEN
             Strng3 = LEFT$(Strng3, Ycoor - Column) + MID$(Strng3, Ycoor - Column + 2)
             CALL ANSI2(2, Xcoor, Ycoor)
             Strng = MID$(Strng3, Ycoor - Column + 1) + " "
             CALL Scrn2(Strng)
          END IF
       CASE 71, 73 ' home/pageup
          Ycoor = Column
       CASE 79, 81 ' end/pagedn
          Ycoor = LEN(Strng3) + Column
       CASE 15 ' tab
          IF Ycoor - Column - 8 > False THEN
             Ycoor = Ycoor - 8
          ELSE
             Ycoor = Column
          END IF
       CASE 77, 72, 157, 141, 132, 152 ' right/up
          IF Ycoor - Column + 1 <= LEN(Strng3) THEN
             Ycoor = Ycoor + 1
          END IF
       CASE 75, 80, 155, 145, 118, 160 ' left/down
          IF Ycoor - Column > False THEN
             Ycoor = Ycoor - 1
          END IF
       CASE 119 ' control-home
          Ycoor = Column
       CASE 117 ' control-end
          Ycoor = LEN(Strng3) + Column
       CASE 116 ' control-right
          DO
             FOR Temp2 = Ycoor - Column + 1 TO LEN(Strng3) - 1
                IF MID$(Strng3, Temp2, 1) = " " THEN
                   IF MID$(Strng3, Temp2 + 1, 1) <> " " THEN
                      Ycoor = Temp2 + Column
                      EXIT DO
                   END IF
                END IF
             NEXT
             IF Ycoor - Column + 1 <= LEN(Strng3) THEN
                Ycoor = LEN(Strng3) + Column
             END IF
             EXIT DO
          LOOP
       CASE 115 ' control-left
          DO
             FOR Temp2 = Ycoor - Column - 1 TO 1 STEP -1
                IF MID$(Strng3, Temp2, 1) = " " THEN
                   Ycoor = Temp2 + Column
                   EXIT DO
                END IF
             NEXT
             IF Ycoor <> Column THEN
                Ycoor = Column
             END IF
             EXIT DO
          LOOP
       END SELECT
    END SELECT
 LOOP
 CALL ANSI2(4, 37, 44)
 CALL ANSI2(2, 4, 75)
 Strng = SPACE$(3)
 CALL Scrn2(Strng)
 Locate , , 1, 7, 7
Error.Resume47:
 EXIT SUB
Error.Trap47:
 RESUME Error.Resume47
END SUB

SUB ANSI2 (VarX, VarY, VarZ)
 ON LOCAL ERROR GOTO Error.Trap16
 ' reset default ansi colors
 If VarX = 1 Or VarX = 4 Then
    VarY = Temp.Array1(VarY)
    VarZ = Temp.Array2(VarZ)
 Endif

 ' process an ansi command
 IF Local.ANSI.Color THEN
    Var$ = Nul
    SELECT CASE VarX
    CASE 1 ' reset/change color
       Var$ = CHR$(27) + "[0;" + MID$(STR$(VarY), 2) + ";" + MID$(STR$(VarZ), 2) + "m"
    CASE 2 ' locate cursor
       Var$ = CHR$(27) + "[" + MID$(STR$(VarY), 2) + ";" + MID$(STR$(VarZ), 2) + "H"
    CASE 4 ' hilight color
       Var$ = CHR$(27) + "[1;" + MID$(STR$(VarY), 2) + ";" + MID$(STR$(VarZ), 2) + "m"
    END SELECT
    CALL Scrn2(Var$)
    EXIT SUB
 END IF

 ' process a text command
 SELECT CASE VarX
 CASE 1
    CALL Convert.Color2(VarY, VarZ, True)
 CASE 2
    Locate VarY, VarZ, 1
 CASE 4
    CALL Convert.Color2(VarY, VarZ, False)
 END SELECT
Error.Resume16:
 EXIT SUB
Error.Trap16:
 RESUME Error.Resume16
END SUB

SUB Convert.Color2 (VarX, VarY, VarZ)
 ON LOCAL ERROR GOTO Error.Trap19
 SELECT CASE VarX
 CASE 30
    VarF = 8
 CASE 31
    VarF = 12
 CASE 32
    VarF = 10
 CASE 33
    VarF = 14
 CASE 34
    VarF = 9
 CASE 35
    VarF = 13
 CASE 36
    VarF = 11
 CASE 37
    VarF = 15
 END SELECT
 SELECT CASE VarY
 CASE 40
    VarB = 8
 CASE 41
    VarB = 12
 CASE 42
    VarB = 10
 CASE 43
    VarB = 14
 CASE 44
    VarB = 9
 CASE 45
    VarB = 13
 CASE 46
    VarB = 11
 CASE 47
    VarB = 15
 END SELECT
 IF VarZ THEN ' reset color
    VarF = VarF - 8
    VarB = VarB - 8
 END IF
 COLOR VarF, VarB
Error.Resume19:
 EXIT SUB
Error.Trap19:
 RESUME Error.Resume19
END SUB

SUB Scrn2 (Var$)
 ON LOCAL ERROR GOTO Error.Trap17
 IF Local.ANSI.Color THEN
    FOR VarX = 1 TO LEN(Var$)
       VarY = ASC(MID$(Var$, VarX, 1))
       Call StdinInt(6,VarY)
    NEXT
    EXIT SUB
 END IF
 PRINT Var$;
Error.Resume17:
 EXIT SUB
Error.Trap17:
 RESUME Error.Resume17
END SUB
