

proc dfile_rm_winmarks {fin fout} {

   set fp [open $fin "r"]
   set fout [open $fout "w"]
   set n 1
   while {![eof $fp]} {
       set one [gets $fp]
       puts $fout $one
       if {![expr $n % 100]} {puts "line $n"}
       incr n
   }
   close $fp
   close $fout
}

proc dfile_open {fname ac} {
   if [catch {set fp [open $fname $ac]} err_msg] {
      mess "$err_msg\n" red
      return ""
   } else {
      return $fp
   }
}

proc dfile_is_numline {fp} {
   set r1 ""; set m 1
   while 1 {
      if [eof $fp] {set m 0; break}
      set r1 [gets $fp]
      if {$r1 != ""} {
         foreach a $r1 {
            if {![string is double $a]} { set m 0; break }
         }
         break
      }
   }
   return [list $m $r1]
}

proc dfile_skip_lines_til_numbers {fp {print_cmd ""}} {
   set r1 ""; set m 1
   while {$m} {
      if [eof $fp] {set r1 ""; break}
      set r1 [gets $fp]
      if {[info command $print_cmd] != ""} {$print_cmd $r1}
      if {$r1 != ""} {set m 0}
      foreach a $r1 {
         if {![string is double $a]} { set m 1; break }
      }
   }
   return $r1
}
