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 

.tcl search in .txt file with -nocase help
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Bart
Voice


Joined: 23 Aug 2016
Posts: 7

PostPosted: Mon Jan 09, 2017 12:53 pm    Post subject: Reply with quote

Is it possible to display the line number?
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 502
Location: Tennessee, USA

PostPosted: Mon Jan 09, 2017 2:01 pm    Post subject: Reply with quote

Bart: in tcl everything is possible...

Which version of the script are you using? (sort from top or bottom)
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
Back to top
View user's profile Send private message Visit poster's website
Bart
Voice


Joined: 23 Aug 2016
Posts: 7

PostPosted: Mon Jan 09, 2017 2:22 pm    Post subject: Reply with quote

SpiKe^^ wrote:
Which version of the script are you using? (sort from top or bottom)

This: http://forum.egghelp.org/viewtopic.php?p=101084#101084
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 502
Location: Tennessee, USA

PostPosted: Mon Jan 09, 2017 2:52 pm    Post subject: Reply with quote

Let's try this and see what we don't like about it:)

Code:

####################################################################################################
putlog "TextSearcher v0.2 - 1st Offcial Release by IsP (q_lander@hotmail.com)"
#
# This script simply searches a txt file (or text files) for search criteria specified via pub
# or msg commands. It Lets you search within a text file for key words using case insensitive
# trigger commands.
#
# Test on eggdrop v1.6.X.....use at own risk ;)
#
# This script was originally made from another script for 1Real by y0manda,
#    rewritten from ground up by IsP@Underent.org
#
# TODO:
# - You tell me?
#
# v0.1 - 1st scripted
# v0.2 - Fixed the counter to display the correct count!
#      - Minor bug fix with proc $args - opps, was a mistake, honest ;P
#
####################################################################################################

#Where are the data files? (Use "{file location1} {file location2} {file location 3} {etc...}")
set cd_release "scripts/MCC/search_file"

#Which channels do I check for the command?
set rlschans "#BotZone"

#Max number of outputs?
set rlsmaxsearch 9

#What's the public trigger?
set cmdsearch "!search"

#What Users are allowed to use this trigger/command? (Leave blank for anyone)
set rlsflag ""

#Set your inital tag info here
set rlsinfo ""

########## DO NOT EDIT BELOW ##########
if {$rlsflag == ""} {set rlsflag "-"}
bind pub $rlsflag $cmdsearch rlssearchpub
proc rlssearchpub {nick uhost handle chan arg} {
   global rlschans
   set valch 0
   foreach ch [split $rlschans] {if {$chan == $ch} {set valch 1}}
   if {$valch == 0} {return}
   rlslocate $chan $uhost $handle "PRIVMSG" "$arg"
}

bind msg $rlsflag $cmdsearch rlssearchmsg
proc rlssearchmsg {nick uhost handle arg} {
   global rlschans
   set valch 0
   foreach ch [split $rlschans] {if {[botonchan $ch]} {if {[onchan $nick $ch]} {set valch 1}}}
   if {$valch == 0} {return}
   rlslocate $nick $uhost $handle "PRIVMSG" "$arg"
}

proc rlslocate {nick uhost handle type arg} {
    global rlsmaxsearch cd_release rlsinfo
    if {$arg == ""} {puthelp "$type $nick :Syntax: $cmdsearch <search string>" ;return 0}
    regsub -all -- " " ${arg} "*" rlsarg
    puthelp "$type $nick : $rlsinfo ...Searching for '$rlsarg'"
    set totrlsfound 0
    set alltext ""
    foreach database $cd_release {

        set line 0

        set rlsfile [open $database r]
        while {![eof $rlsfile]} {

         incr line

         set rlsline [gets $rlsfile]

         if {[string match -nocase "*$rlsarg*" $rlsline]} {
            incr totrlsfound 1
 
            lappend alltext "\[$line\] $rlsline"

         }
        }
        close $rlsfile
    }
    if {$alltext != ""} {

      set cnt 0
      foreach allline [lreverse $alltext] {

         incr cnt
         if {$cnt > $rlsmaxsearch} {  break  }

         puthelp "$type $nick : \002Found:\002 $allline"
      }
    }
    if {$totrlsfound > $rlsmaxsearch} {puthelp "$type $nick :There are over $rlsmaxsearch matches. Please be more specific"}
    puthelp "$type $nick :There was a total of $totrlsfound entries matching your query."
}


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
Back to top
View user's profile Send private message Visit poster's website
Bart
Voice


Joined: 23 Aug 2016
Posts: 7

PostPosted: Mon Jan 09, 2017 3:16 pm    Post subject: Reply with quote

Thank you, SpiKe^^.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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