| View previous topic :: View next topic |
| Author |
Message |
whittinghamj Op
Joined: 21 May 2006 Posts: 103
|
Posted: Mon Feb 19, 2007 7:42 pm Post subject: Hhelp with strip char |
|
|
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 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Feb 19, 2007 8:18 pm Post subject: |
|
|
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).
Manpage for 'string' can be found here _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
whittinghamj Op
Joined: 21 May 2006 Posts: 103
|
Posted: Mon Feb 19, 2007 10:06 pm Post subject: |
|
|
thank you so much for the tips - i am changing my script as needed.
One other question.
How do i take the spaces from the irc line and convert them into a period
eg
hello i am new here
would become in the log file
hello.i.am.new.here
any su8ggestions? point me in the right direction / have any sample code i can use as a base to work from please? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Feb 20, 2007 12:49 am Post subject: |
|
|
'string map' would probably be your friend here, assuming you've got tcl8.2 or later installed.
| Code: | | string map [list " " "."] $string |
If 'string map' is not available on your system, you could use regsub instead. Keep in mind that regular expressions can be abit "tricky" however... _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
whittinghamj Op
Joined: 21 May 2006 Posts: 103
|
Posted: Wed Feb 28, 2007 12:11 am Post subject: |
|
|
hi guys
I am trying to use both of those examples but running into issues - no idea how to use them
here is what i have so fare
maybe u can see where i going wrong
| Code: |
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
cheers |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Feb 28, 2007 1:24 am Post subject: |
|
|
set string map [list " " "."] $arg
should be
set varname [string map {" " "."} $arg]
No clue what this is trying to accomplish:
set pregroup [string range [lindex $arg 0] [expr {[string last - [lindex $arg 0]] + 1}] end ]
Maybe try reading the manpages for 'string' and 'lindex' instead of just randomly mix-mashing these together like that. |
|
| Back to top |
|
 |
whittinghamj Op
Joined: 21 May 2006 Posts: 103
|
Posted: Wed Feb 28, 2007 1:48 am Post subject: |
|
|
I got it thank you
I was not thinking right - been at this tcl for 9 hours non stop lol |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Wed Feb 28, 2007 1:50 pm Post subject: |
|
|
sigh.
If we are truely supposed to be against helping people setting up things related to warez, why are we still helping them? |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Feb 28, 2007 7:59 pm Post subject: |
|
|
| metroid wrote: | sigh.
If we are truely supposed to be against helping people setting up things related to warez, why are we still helping them? |
Guess I didn't think of it in that light. |
|
| Back to top |
|
 |
|