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.

search txt file problem

Old posts that have not been replied to for several years.
Locked
J
Jagg
Halfop
Posts: 53
Joined: Sat Jan 24, 2004 11:32 am

search txt file problem

Post by Jagg »

Hi,

i have found a script here in the forum to search a txt file line by line and post the results if $arg is in this file.

My sample txt file looks like
---------------------------------
boardseek => http://any.url.com
help-agent => this is a text
---------------------------------

I modified it to my needs as shown below and when I search after "board" or "boardseek" i get the correct result "boardseek".

But when i search after "help" or "help-agent" i get nothing :? !

Why?

Code: Select all

# header and copyright......
# .....
#
set cd_release "{./scripts/myfile.txt}"
set rlsmaxsearch 10
set cmdsearch "!search"
set rlsflag ""

if {$rlsflag == ""} {set rlsflag "-"}
bind pub $rlsflag $cmdsearch pub:rlslocate

proc pub:rlslocate {nick uhost handle chan arg} {
global rlsmaxsearch cd_release
if {[lindex $arg 0] == ""} {puthelp "PRIVMSG $chan :Syntax: $cmdsearch <Suchwort>" ;return 0}
set totrlsfound 0

foreach database $cd_release {
  set rlsfile [open $database r]

    while {![eof $rlsfile]} {
    set rlsline [gets $rlsfile]
    if {[string match "*[string tolower [lindex $arg 0]]*" [string tolower $rlsline]]} {
    incr totrlsfound 1
      if {$totrlsfound < $rlsmaxsearch} { 
      puthelp "PRIVMSG $chan :$totrlsfound. Teffer: [lindex $rlsline 0]"
      }
     }
    }

close $rlsfile
}

if {$totrlsfound > $rlsmaxsearch} {puthelp "$PRIVMSG $chan :$nick: Es gab mehr wie $rlsmaxsearch Treffer. Bitte etwas eingrenzen!"}
if {$totrlsfound == "0" } {puthelp "PRIVMSG $chan :$nick: Es gab $totrlsfound Einträge, die deiner Suchanfrage entsprachen."}
if {$totrlsfound == "1" } {puthelp "PRIVMSG $chan :$nick: Es gab $totrlsfound Eintrag, der deiner Suchanfrage entsprach."}
if {$totrlsfound >= 2 } {puthelp "PRIVMSG $chan :$nick: Es gab $totrlsfound Einträge, die deiner Suchanfrage entsprachen."}
}
Last edited by Jagg on Tue Jan 18, 2005 9:22 am, edited 1 time in total.
J
Jagg
Halfop
Posts: 53
Joined: Sat Jan 24, 2004 11:32 am

Post by Jagg »

Ok, works now (corrected code in first post)...
Locked