I'm using lappend to add nicks to a variable when nick joins, what I want to do is a timer which calls a proc after few seconds and removes this nick from the variable, but I couldn't find out a way to do that. Does anybody have any ideas ?
Sir_Fz wrote:I'm using lappend to add nicks to a variable when nick joins, what I want to do is a timer which calls a proc after few seconds and removes this nick from the variable, but I couldn't find out a way to do that. Does anybody have any ideas ?
Does each person joining have a unique delay before removal? If not: there's no need to keep track of the order/search - just make the timer remove the first element in the list as it will always be the oldest one.
« Opposing » .tcl set someo "a b c d e"
« bot » Tcl: a b c d e
« Opposing » .tcl lreplace $someo [lsearch $someo b] [lsearch $someo b] ""
« bot » Tcl: a {} c d e
« Opposing » .tcl set someo
« bot » Tcl: a b c d e
as you see the element b is still in the someo variable.
lreplace doesn't change variables. It takes a list as input and gives a list as output. To have the value stored you must do it yourself. If you want to remove an element, don't specify a replacement value ("" will replace the range with an empty element)