Posted to tcl by tarsonis at Sat Aug 11 16:11:05 GMT 2007view raw

  1. proc cmd_plot {nick host hand chan text} {
  2. set input_a [open "lebewesen.txt" r]
  3. set lines_a [countLines lebewesen.txt]
  4. set data_a [read $input_a]
  5. close $input_a
  6. foreach i {1 2 3 4 5} {
  7. set input_s($i) [open "story$i.txt" r]
  8. set lines_s($i) [countLines story$i.txt]
  9. set data_s($i) [read $input_s($i)]
  10. close $input_s($i)
  11. set story($i) [lindex [split $data_s($i) \n] [random $lines_s($i)]]
  12. }
  13. set animal1 [lindex [split $data_a \n] [random $lines_a]]
  14. set animal1 [trimIt $animal1]
  15. set animal2 [lindex [split $data_a \n] [random $lines_a]]
  16. set animal2 [trimIt $animal2]
  17. foreach e {1 2 3 4 5} {
  18. if {[lsearch $story($e) animal1] != -1} {
  19. foreach i [lsearch -all $story($e) animal1] {
  20. set story($e) [string trimleft [string trimright [lreplace $story($e) $i $i $animal1] \}] \{]
  21. }
  22. }
  23. if {[lsearch $story($e) animal2] != -1} {
  24. foreach i [lsearch -all $story($e) animal2] {
  25. set story($e) [string trimleft [string trimright [lreplace $story($e) $i $i $animal2] \}] \{]
  26. }
  27. }
  28. }
  29. putchan $chan "$story(1). $story(2). $story(3), $story(4). $story(5). Ende."
  30. }
  31.