      CHARACTER*1 A(24)
      CHARACTER*8 FORE,BACK,BORD
      WRITE(*,*)' INPUT COLORS FOR FOREGROUND BACKGROUND AND BORDER'
      READ(IN,1) (A(I),I=1,24)
    1 FORMAT(24A1)
      J = 0
      DO 2 I=1,24
      IF(A(I).EQ.' ' .OR. A(I).EQ.',')GO TO 3
    2 J = J + 1
    3 FORE=A(1:J)
      KF = J + 2
      DO 5 I =KF,24
      IF(A(I).EQ.' ' .OR. A(I).EQ.',')GO TO 6
    5 KL = I + 1
    6 BACK = A(KF:(KL-1))
      LF = KL + 1
      DO 4 I=LF,24
      IF(A(I).EQ.' ' .OR. A(I).EQ.',')GO TO 7
    4 LL = I + 1
    7 BORD = A(LF:(LL-1))
      IF(BACK.EQ.'BLACK'   .OR. BACK .EQ.'black'   )GO to 10
      IF(BACK.EQ.'BLUE'    .OR. BACK .EQ. 'blue'   )GO TO 11
      IF(BACK.EQ.'GREEN'   .OR. BACK .EQ. 'green'  )GO to 12
      IF(BACK.EQ.'CYAN'    .OR. BACK .EQ. 'cyan'   )GO TO 13
      IF(BACK.EQ.'RED'     .OR. BACK .EQ. 'red'    )GO TO 14
      IF(BACK.EQ.'MAGENTA' .OR. BACK .EQ. 'magenta')GO TO 15
      IF(BACK.EQ.'BROWN'   .OR. BACK .EQ. 'brown'  )GO TO 16
      IF(BACK.EQ.'WHITE'   .OR. BACK .EQ. 'white'  )GO TO 17
      IF(BACK.EQ.'YELLOW'  .OR. BACK .EQ. 'yellow' )GO TO 16
   10 M2 = 0
      GO TO 100
   11 M2 = 1
      GO TO 100
   12 M2 = 2
      GO TO 100
   13 M2 = 3
      GO TO 100
   14 M2 = 4
      GO TO 100
   15 M2 = 5
      GO TO 100
   16 M2 = 6
      GO TO 100
   17 M2 = 7
  100 IF(FORE.EQ.'BLACK'  )GO TO 20
      IF(FORE.EQ.'BLUE'   )GO TO 21
      IF(FORE.EQ.'GREEN'  )GO TO 22
      IF(FORE.EQ.'CYAN'   )GO TO 23
      IF(FORE.EQ.'RED'    )GO TO 24
      IF(FORE.EQ.'MAGENTA')GO TO 25
      IF(FORE.EQ.'BROWN'  )GO TO 26
      IF(FORE.EQ.'WHITE'  )GO TO 27
      IF(FORE.EQ.'GRAY'   )GO TO 28
      IF(FORE.EQ.'gray'   )GO TO 28
      IF(FORE.EQ.'blue'   )GO TO 29
      IF(FORE.EQ.'green'   )GO TO 210
      IF(FORE.EQ.'cyan'   )GO TO 211
      IF(FORE.EQ.'red'    )GO TO 212
      IF(FORE.EQ.'magenta')GO TO 213
      IF(FORE.EQ.'yellow' )GO TO 214
      IF(FORE.EQ.'YELLOW' )GO TO 214
      IF(FORE.EQ.'white'  )GO TO 215
   20 M1 = 0
      GO TO 101
   21 M1 = 1
      GO TO 101
   22 M1 = 2
      GO TO 101
   23 M1 = 3
      GO TO 101
   24 M1 = 4
      GO TO 101
   25 M1 = 5
      GO TO 101
   26 M1 = 6
      GO TO 101
   27 M1 = 7
      GO TO 101
   28 M1 = 8
      GO TO 101
   29 M1 = 9
      GO TO 101
  210 M1 = 10
      GO TO 101
  211 M1 = 11
      GO TO 101
  212 M1 = 12
      GO TO 101
  213 M1 = 13
      GO TO 101
  214 M1 = 14
      GO TO 101
  215 M1 = 15
  101 IF(BORD.EQ.'BLACK'  )GO TO 30
      IF(BORD.EQ.'BLUE'   )GO TO 31
      IF(BORD.EQ.'GREEN'  )GO TO 32
      IF(BORD.EQ.'CYAN'   )GO TO 33
      IF(BORD.EQ.'RED'    )GO TO 34
      IF(BORD.EQ.'MAGENTA')GO TO 35
      IF(BORD.EQ.'BROWN'  )GO TO 36
      IF(BORD.EQ.'WHITE'  )GO TO 37
      IF(BORD.EQ.'GRAY'   )GO TO 38
      IF(BORD.EQ.'gray'   )GO TO 38
      IF(BORD.EQ.'blue'   )GO TO 39
      IF(BORD.EQ.'green'  )GO TO 310
      IF(BORD.EQ.'cyan'   )GO TO 311
      IF(BORD.EQ.'red'    )GO TO 312
      IF(BORD.EQ.'magenta')GO TO 313
      IF(BORD.EQ.'YELLOW' )GO TO 314
      IF(BORD.EQ.'yellow' )GO TO 314
      IF(BORD.EQ.'white'   )GO TO 315
   30 M3 = 0
      GO TO 102
   31 M3 = 1
      GO TO 102
   32 M3 = 2
      GO TO 102
   33 M3 = 3
      GO TO 102
   34 M3 = 4
      GO TO 102
   35 M3 = 5
      GO TO 102
   36 M3 = 6
      GO TO 102
   37 M3 = 7
      GO TO 102
   38 M3 = 8
      GO TO 102
   39 M3 = 9
      GO TO 102
  310 M3 = 10
      GO TO 102
  311 M3 = 11
      GO TO 102
  312 M3 = 12
      GO TO 102
  313 M3 = 13
      GO TO 102
  314 M3 = 14
      GO TO 102
  315 M3 = 15
  102 OPEN(20,FILE='INP.BAT',STATUS='NEW')
      IF(M1.GT.9 .AND. M3.GT.9 )GO TO 400
      IF(M1.LE.9 .AND. M3.GT.9 ) GO TO 402
      IF(M1.GT.9 .AND. M3.LE.9)GO TO 403
      WRITE(20,104)'COLOR',M1,M2,M3
      GO TO 404
  400 WRITE(20,103)'COLOR',M1,M2,M3
      GO TO 404
  402 WRITE(20,105)'COLOR',M1,M2,M3
      GO TO 404
  403 WRITE(20,106)'COLOR',M1,M2,M3
  104 FORMAT(A5,1XI1,1XI1,1XI1)
  103 FORMAT(A5,1XI2,1XI1,1XI2)
  105 FORMAT(A5,1XI1,1XI1,1XI2)
  106 FORMAT(A5,1XI2,1XI1,1XI1)
  107 FORMAT(1XA4)
  404 WRITE(20,107)'CLS1'



      WRITE(20,107)' CLS'
      CLOSE(20,STATUS='KEEP')
      END
