FUNCTION  EnterColour()
local $fldlen $usedlen
  $fldlen = dbfldinfo("[Colours]",2)
  $usedlen = str(len([Colours]))
  while true
    x = entryline(" Enter Colour Description or {Esc} to abandon ",20,"","",21,5,72)
    if x = 0
      if ptstr = ""
        continue while
      end if
      $color = proper(ptstr)
      if len(ptstr) > (value($fldlen) - value($usedlen))
        return (1)   ' !!!!!!!!!!!!!!!! TEST ONLY
      end if
      x = messline(" Confirm new Colour -"&$color|"? (y/n)",1,1,1,21,5,72)
      if x = 0
        if ptstr == "n"
          continue while
        else
          x = CheckDupe($color)		'  0    OK
          if x = 0 			' -1    maybe - show popup
            exit while                  ' -2    DUPLICATE
          elseif x = -1
            scr = scr - 2
            messline($color&"- duplicated?",0,0,1,21,5,72)
            y2 = format(" "|chr(24)&chr(25)&"to find - {Enter} to select colour - {Esc} if not listed ","M72")
            screen print 21 5 fgp bgp y2
            screen shortrestore dsa
            x = popuplist(8,57,18,[Colours],"",1,0)
            if x = -1			' {Esc} pressed
              x = messline(" Confirm "|$color&"(y/n)",1,1,1,21,5,72)
              if ptstr == "y"
                scr = scr + 2
                exit while
              else
                continue while
              end if
            else                        ' Alternative selected
              $newcolor = ptstr
              scr = scr + 2
              exit while
            end if
          elseif x = -2
            continue while
          end if
        end if
      end if
    elseif x = -1
      return (-1)
    end if
  end while

  y = strtoary($color)
  $newcolor = ""
  for i = 1 to ptval
    if i = 1
      $newcolor = ptary[i]                ' NB - space is Alt-255
    else
      $newcolor = $newcolor|"ÿ"|ptary[i]    ' NB - space is Alt-255
    end if
  end for

  $unsort = [Colours]&trim($newcolor)
  repaint off
  SortColour()
  vloadif(dpath|"prodsel"|$prodend|".vw")

  lock-record
    [Colours] = $newsort
  write-record
  return (0)
END FUNCTION ' EnterColour()
