This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

trimleft and other string problems

Help for those learning Tcl or writing their own scripts.
Post Reply
l
lacedrabbit
Voice
Posts: 3
Joined: Tue Sep 25, 2007 3:33 am

trimleft and other string problems

Post by lacedrabbit »

Hello There,
i have read nearly every forum post relating to this problem
ive search and everything, heres my problem

I've logged a chan output to logfile, i've brought it back in
gave it a string and everything, worked out how to strip the colors from it

heres the code i have..

Code: Select all

               if {[file exists $searchfile]} {

                        set filech [open $searchfile r]

                        while {![eof $filech]} {
                                gets $filech line

                                set edline $line
                                set edline2 $line
                                set endofname "x"

                                set lwrtext [string tolower $text]
                                set lwrcase [string tolower $edline]
                                set strip [stripcodes bcruag $edline2]

                                if {[string match *$lwrtext* $lwrcase] && [string match *#* $edline] } {
                                                        puthelp "PRIVMSG #melwakechan : Result - [string trimleft $strip "#"] -"
                                                                }
                                }
                        }

                close $filech
from my view point I can't see why it doesn't take info out of the output
this is just my final way of coding it, I have tried many, all of which failing

finding the line is not the problem here, what I want to do is format the line so I can do something useful with it. this is just the start of this application, but it doesn't make any sense at all to me..

Even a Your making no sense here would be appreciated

this is what I am getting in the channel, I would have thought from my reading that everything to the left of the # would be gone,or even just no #.
Result - [03:05] <[am]-32263> #4  1x [705M] Oceans.13.R5.Line.XViD-ViSUAL.avi -
Thanks.
lacedrabbit
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

if {[string match *$lwrtext* $lwrcase] && [string match *#* $edline] } {
I think you should try:

Code: Select all

if {[string match -nocase $lwrtext $lwrcase] && [string match -nocase *#* $edline] } { 
and use

* in $lwrtext

for Example:

Code: Select all

set lwrtext { "*text1*" "*text2*" "*text3*" }
Then use it in proc and don't forget to take it into Global

Code: Select all

foreach lwrtext $lwrtext { if {[string match -nocase "$lwrtext" $lwrcase] && [string match -nocase *#* $edline]} {
I am not sure about it but once I had the same problem I solved it with that.

Thanks
iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
l
lacedrabbit
Voice
Posts: 3
Joined: Tue Sep 25, 2007 3:33 am

Post by lacedrabbit »

Ok, heres a tidied up version - thanks 'iamdeath'

Code: Select all

                if {[file exists $searchfile]} {
                        set filech [open $searchfile r]
                        while {![eof $filech]} {
                                gets $filech line
                                set edline $line
                                set strip [stripcodes bcruag $edline]
                                if {[string match -nocase *$text* $edline] && [string match -nocase *#* $edline] } {
                                        puthelp "PRIVMSG #melwakechan : Result - [string trimleft $strip "#"] -"
                                                }
                        }
                close $filech
                }
although your advice helped tidied up my code, and I am grateful,
but I still have the output problem, I would like to get rid of the text to the left of the '#'
Result - [17:10] <Jory`> #11 «701 MB» Wrong.Turn.2.LIMITED.DVDSCR.XViD-mVs - (4 gets) -
does anyone know of a good url for reference for string manipulation as every sight I have read says this should be working.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Post Reply