Hi guys. when I am logging a line of text from #channel to logfile. How do I strip of the last charactor before writing the line to the logfile?
Some of my users have this dam annoying script which puts [ and ] start and end of every line they type.
Now I can miss out the first [ by lindex $text 1 end] and it works perfectly - just need to drop the VERY last char which happens to be a ] - as its logged in the file as \] - which is very annoying and very ugly.
Any help please --- I looked around the board for the strip syntax but I am either not really understanding it right or the posted did not seem line they would help any.
Thanks guys -
PS - its about time but I am writing my own darn script and not just requesting the full script this time he he - yay Quest
First off, don't ever use lrange (or lindex for that matter) in that fashion!
lrange is supposed to be used on lists, not plain text. What you should be using is 'string range' or possibly 'string strip'.
As for getting correct ranges for either lrange or string range, use end-1 as end-of-range argument to drop the last char (string range) or list item (lrange).
proc pub:addpreannounce {nick host hand chan arg} {
global mysql
set pregroup [string range [lindex $arg 0] [expr {[string last - [lindex $arg 0]] + 1}] end ]
set rlstime [unixtime]
set string map [list " " "."] $arg
set rlsname [lindex $string 10]
set rlssection [lindex $arg 6]
there is some code after this but that part works fine