Ok I am ok so far with this but would like to slow down the pasting of each line, what it does is read from a specific txt file and paste on line at a time but is doing so too fast, I would like say 3 or 4 seconds between lines also cant understand why it stops before the end of each file.
set tracks [open $filename]
set data [split [read -nonewline $tracks] \n]
close $tracks
foreach trance_line $data {
putserv "PRIVMSG $nick :$trance_line"
}
}
proc Trance_Listing {nick uhost hand text} {
set number "trancelist"
set filename ${::trance_file}/${number}.txt
set tracks [open $filename]
set data [split [read -nonewline $tracks] \n]
close $tracks
foreach trance_line $data {
putserv "PRIVMSG $nick :$trance_line "
}
}
Ok i can see what you mean but i dont have a clue how to put that in what I have, that above the user picks the file name and it starts pasting. It would be helpful to know what to do with that in plain english or how it is in relationship to what I have cheers
Sure,
What I do, is rather than having a foreach-loop iterate through all lines at once, I use timers to repeatedly call my proc named "tellNextLine". This proc then reads the next line from the (already opened) file and sends it to the target, and then starts a new timer (to call tellNextLine again), until there are no more lines remaining in the file ("gets" returns less than 0 bytes read). I then close the file to preserve file descriptors.
Also, rather than read the whole file into memory at once, I leave the file open and only read the one line I need at the moment. Since we're using such a slow pace for sending messages, there's no real benefit from caching the texts in memory.
Other than that, I skipped some temporary variables you've used. The code I wrote should be able to completely replace the code from your original post.