set winNum 0

set types [exec cut -d " " -f 5 messages.1 | cut -d {[} -f 1 | sort -u]

# Initialized inside this loop
set column 1

foreach type $types {
  exec grep $type messages.1 > tmpFile
  set days [exec  cut -d " " -f 2 tmpFile | sort -u]

  # Loop for the messages we know are in this file
  set column [expr {$column + 1}]
  label .type_$winNum -text "$type " 
  grid .type_$winNum -row 0 -column $column
  set winNum [expr $winNum + 1]

  foreach day $days {

    # Create a label for the day and grid it
    # Note that the $day variable is used for the row 
    # The grid command ignores empty rows and columns, so this leaves
    #   no blank spaces.
    label .day_$winNum -text "Dec $day"
    grid .day_$winNum -row $day -column 1

    # create a new winNum for the next window
    set winNum [expr $winNum + 1]
  
    # A new label : note the -borderwidth and -relief options 
    # these make the labels obviously separate
    set count [exec  grep "Dec $day" tmpFile | wc -l]
    label .type_$winNum -text "$count" 
    grid .type_$winNum -row $day -column $column

    # Create new winNum and Step to next column
    set winNum [expr $winNum + 1]
    update idle
  }
}


