Posted to tcl by tarsonis at Sat Aug 11 16:11:05 GMT 2007view raw
- proc cmd_plot {nick host hand chan text} {
- set input_a [open "lebewesen.txt" r]
- set lines_a [countLines lebewesen.txt]
- set data_a [read $input_a]
- close $input_a
- foreach i {1 2 3 4 5} {
- set input_s($i) [open "story$i.txt" r]
- set lines_s($i) [countLines story$i.txt]
- set data_s($i) [read $input_s($i)]
- close $input_s($i)
- set story($i) [lindex [split $data_s($i) \n] [random $lines_s($i)]]
- }
- set animal1 [lindex [split $data_a \n] [random $lines_a]]
- set animal1 [trimIt $animal1]
- set animal2 [lindex [split $data_a \n] [random $lines_a]]
- set animal2 [trimIt $animal2]
- foreach e {1 2 3 4 5} {
- if {[lsearch $story($e) animal1] != -1} {
- foreach i [lsearch -all $story($e) animal1] {
- set story($e) [string trimleft [string trimright [lreplace $story($e) $i $i $animal1] \}] \{]
- }
- }
- if {[lsearch $story($e) animal2] != -1} {
- foreach i [lsearch -all $story($e) animal2] {
- set story($e) [string trimleft [string trimright [lreplace $story($e) $i $i $animal2] \}] \{]
- }
- }
- }
- putchan $chan "$story(1). $story(2). $story(3), $story(4). $story(5). Ende."
- }