egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

trimleft and other string problems

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
lacedrabbit
Voice


Joined: 25 Sep 2007
Posts: 3

PostPosted: Wed Oct 03, 2007 9:25 am    Post subject: trimleft and other string problems Reply with quote

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:

               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 #.

Quote:

Result - [03:05] <[am]-32263> #4  1x [705M] Oceans.13.R5.Line.XViD-ViSUAL.avi -


Thanks.
lacedrabbit
Back to top
View user's profile Send private message Send e-mail
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Wed Oct 03, 2007 2:17 pm    Post subject: Reply with quote

Quote:
if {[string match *$lwrtext* $lwrcase] && [string match *#* $edline] } {


I think you should try:

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


and use

* in $lwrtext

for Example:

Code:
set lwrtext { "*text1*" "*text2*" "*text3*" }

Then use it in proc and don't forget to take it into Global

Code:
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*...
Back to top
View user's profile Send private message Visit poster's website
lacedrabbit
Voice


Joined: 25 Sep 2007
Posts: 3

PostPosted: Wed Oct 03, 2007 6:18 pm    Post subject: Reply with quote

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

Code:

                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 '#'

Quote:

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.
Back to top
View user's profile Send private message Send e-mail
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Oct 03, 2007 7:22 pm    Post subject: Reply with quote

This page might help: Tcl Built-In Commands - string manual page Very Happy
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber