title: How to save incoming variables from serial port into a list
body: <p>I want to save 7 variables incoming over a serial port. The transmission starts with an empty line, followed by 7 lines, each consisting of a single variable. No blanks but a carriage return at every line end. Each variable can also consists of blanks. This is carried out repeatedly.
  If the empty line would cause a problem, it coud be omitted in my external device.</p>
  
  <pre><code>#!/ usr /bin/env wish
  
  console show
  set Term(Port) com5
  set Term(Mode) "9600,n,8,1"
  
  set result [list]
  set data {}
  
  proc receiver {chan} {
  
      set data [gets $chan]
      concat {*}[split $data \n]
      set ::result [split $data "\n"]
      #puts $data
      #puts $::result
      #foreach Element $::result {     
      #puts $Element}
      #puts "Element 0  [lindex $::result 0]"
      #puts "Element 1  [lindex $::result 1]"
  
      return
  }
  
   set chan [open $Term(Port) r+]
   fconfigure $chan -mode $Term(Mode) -translation binary -buffering none -blocking 0
   fileevent $chan readable [list receiver $chan]
  </code></pre>
  
  <p><code>puts $data</code> shows the following:</p>
  
  <pre><code>START
  
  ChME3    
  
  562264  
  
  Lok3     
  Lok4      
  
  
  Lok6     
  </code></pre>
  
  <p>All the 7 variables are visible but with empty lines inbetween. The empty line between "Lok4" and "Lok6" seems to be ok, since this is a variable consisting of blanks.</p>
  
  <p>I tried to create a list with <code>set ::result [split $data "\n"]</code>. But that isn't working properly. With <code>foreach Element $::result {puts $Element}</code> the console shows the 7 variables:</p>
  
  <pre><code>START     
  ChME3     
  562264    
  Lok3      
  Lok4      
  .          
  Lok6
  </code></pre>
  
  <p>I have inserted the point between Lok4 and Lok6 manually here in the blockquote just for display purposes. In reality it's a variable consisting of only blanks.</p>
  
  <p>Despite it looks like a list, if I try <code>
  puts "Element 0  [lindex $::result 0]"
  puts "Element 1  [lindex $::result 1]"</code></p>
  
  <p>it shows</p>
  
  <pre><code>Element 0 START  
  Element 1        
  Element 0 ChME3  
  Element 1        
  Element 0 562264 
  </code></pre>
  
  <p>and so on.
  Element 1 remains empty and Element 0 is consecutively assigned with each variable.
  So it is clearly not a list. But I wonder, why <code>foreach Element $::result {puts $Element}</code>seems to work? What do I have to change to get a real list?</p>