Posted to tcl by Saedelaere at Fri Nov 16 21:30:06 GMT 2007view raw

  1. #! /bin/sh
  2. # the next line restarts using wish \
  3. exec wish "$0" "$@"
  4.  
  5. set home_path $::env(HOME)
  6.  
  7. proc channel_up {} {
  8. set file $::home_path/.tv-viewer/config/channels.conf
  9. set f [open $file r]
  10. set i 1
  11. while {[gets $f line]!=-1} {
  12. if { "$::kanalid($i)" == "ZDF" } {
  13. puts $i
  14. set rechnung [expr {($i == 30) ? 1 : ($i + 1)}]
  15. puts $rechnung
  16. puts $::kanalid($rechnung)
  17. }
  18. incr i
  19. }
  20. }
  21.  
  22. proc channel_down {} {
  23. set file $::home_path/.tv-viewer/config/channels.conf
  24. set f [open $file r]
  25. set i 1
  26. while {[gets $f line]!=-1} {
  27. if { "$::kanalid($i)" == "ARD" } {
  28. set rechnung [expr {($i == 1) ? 30 : ($i - 1)}]
  29. puts $rechnung
  30. puts $::kanalid($rechnung)
  31. }
  32. incr i
  33. }
  34. }
  35.  
  36. set file $::home_path/.tv-viewer/config/channels.conf
  37. set f [open $file r]
  38. set i 1
  39. while {[gets $f line]!=-1} {
  40. foreach {kanal channel} [split $line] {
  41. set kanalid($i) $kanal
  42. }
  43. incr i
  44. }
  45. channel_down
  46.  
  47. I'am sure this could be done much better. But it works and is much better than the code i used to have.
  48. Thanks to all of you
  49.