mIRC Home    About    Download    Register    News    Help

Print Thread
#29415 12/06/03 05:41 PM
Joined: Jan 2003
Posts: 27
S
Spoof Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jan 2003
Posts: 27
I wanna write a script wtch check for a for a word in txt file.
for exampe
If (word isin file.txt) commands ...
But i dont have idea how to do it can you help me pls


Tullamore Dew
#29416 12/06/03 05:51 PM
Joined: Jan 2003
Posts: 148
K
Vogon poet
Offline
Vogon poet
K
Joined: Jan 2003
Posts: 148
That depends on... Does the file contain only words or sentences? If it only contains word you can use this code:

Code:
 

if (yourword isin $read(file.txt, s, yourword)) { commands }

 


#29417 12/06/03 06:00 PM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
or for sentences:
if (* $+ yourword $+ * iswm $read(file.txt, w, * $+ yourword $+ *)) { commands }


new username: tidy_trax
#29418 12/06/03 06:15 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
the w param already checks like a "iswm" dumb[censored]

Redundant (ree-done-dant) (adj.)
See redundant

(Now that you saw my post, I can revert to not swearing.)

Last edited by KingTomato; 12/06/03 06:22 PM.

-KingTomato
#29419 12/06/03 06:18 PM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
i dont care thats what i use


new username: tidy_trax
#29420 12/06/03 07:03 PM
Joined: Jan 2003
Posts: 27
S
Spoof Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jan 2003
Posts: 27
/scantext {
while (%x < $lines(channel.txt)) {
inc %x 1
set %scanword 1
while ($gettok(sadsd addfada sex ad,%scanword,32) != $null) {
if ($gettok(sadsd addfada sex ad,%scanword,32) isin $read(channel.txt,w,%x) echo -a BAD WORD
inc %scanword 1
}
}
}

Here the code witch i compose during your posts.but it dosent work


Tullamore Dew
#29421 12/06/03 07:47 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
If you're looking for a swear kick, i have a nice dialog-based one. I won't have it todasy though (my domain is going thru changes) but i can give it to u on irc >:D Look in my info to find me


-KingTomato
#29422 12/06/03 08:06 PM
Joined: Dec 2002
Posts: 169
J
Vogon poet
Offline
Vogon poet
J
Joined: Dec 2002
Posts: 169
No need to go through the entire channel.txt line by line. $read can scan. Here are two aliases. The first will look for only ONE instance of one of the words in the list. The second looks for EVERY instance of one of the words in the list. Usage: /scantext <your list of words to scan for here>
Code:
alias scantext {
  var %i = 1
  while ($gettok($$1-,%i,32) != $null) {
    var %word = $ifmatch
    if ($read($mircdirchannel.txt,w,$+(*,%word,*)) != $null) {
      echo -a BAD WORD: %word
    }
    inc %i
  }
}

alias scantext {
  var %i = 1
  while ($gettok($$1-,%i,32) != $null) {
    var %word = $ifmatch
    var %x = 1 
    while ($read($mircdirchannel.txt,w,$+(*,%word,*),%x) != $null) {
      echo -a BAD WORD: %word - Line $readn
      %x = $readn + 1
    }
    inc %i
  }
}
Here is a third one that uses /filter with regular expressions.
Code:
alias scantext {
  var %regex = (?i) $+ $replace($1-,\,\\,?,\?,*,\*,+,\+,.,\.,|,\|,$chr(123),$+(\,$chr(123)),$chr(125),$+(\,$chr(125)),[,\[,],\],$chr(40),$+(\,$chr(40)),$chr(41),$+(\,$chr(41)),$chr(32),$chr(124))
  if ($window(@temp.scantext) == $null) { window -lh @temp.scantext }
  filter -fwngc $mircdirchannel.txt @temp.scantext %regex
  var %x = 1
  while ($line(@temp.scantext,%x)) {
    echo -a BAD WORD!  Line $gettok($ifmatch,1,32)
    inc %x
  }
  window -c @temp.scantext
}


Last edited by Jerk; 12/06/03 08:09 PM.
#29423 12/06/03 08:34 PM
Joined: Dec 2002
Posts: 169
J
Vogon poet
Offline
Vogon poet
J
Joined: Dec 2002
Posts: 169
I reread your original post. I think this alias might be your best bet:
Code:
alias scantext {
  if ($isid == $false) { echo $color(info) -esti * Scantext needs to be called as an identifier | return }
  if ($0 &lt; 2) { echo $color(info) -esti * Scantext: Not enough paramaters | return }
  var %file = $$1 , %i = 3 , %regex = $replace($2,\,\\,?,\?,*,\*,+,\+,.,\.,|,\|,$chr(123),$+(\,$chr(123)),$chr(125),$+(\,$chr(125)),[,\[,],\],$chr(40),$+(\,$chr(40)),$chr(41),$+(\,$chr(41)))
  while ($eval($+($,%i),2) != $null) {
    %regex = %regex $+ $chr(124) $+ $replace($ifmatch,\,\\,?,\?,*,\*,+,\+,.,\.,|,\|,$chr(123),$+(\,$chr(123)),$chr(125),$+(\,$chr(125)),[,\[,],\],$chr(40),$+(\,$chr(40)),$chr(41),$+(\,$chr(41)))
    inc %i
  }
  if ($prop != cs) { %regex = (?i) $+ %regex }
  if ($window(@temp.scantext) == $null) { window -lh @temp.scantext }
  filter -fwngc %file @temp.scantext %regex
  window -c @temp.scantext
  return $filtered
}

Usage: $scantext(filename,word,word,word,word,...)
Returns number of lines that match. 0 if none.
If you specify the .cs property it will make the search case sensitive: $scantext(file,Jerk).cs

If ($scantext(File.name,sadsd,addfada,sex,ad)) { commands }


Last edited by Jerk; 12/06/03 08:49 PM.

Link Copied to Clipboard