|
Joined: Jan 2003
Posts: 27
Ameglian cow
|
OP
Ameglian cow
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
|
|
|
|
Joined: Jan 2003
Posts: 148
Vogon poet
|
Vogon poet
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:
if (yourword isin $read(file.txt, s, yourword)) { commands }
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
Joined: May 2003
Posts: 2,265 |
or for sentences: if (* $+ yourword $+ * iswm $read(file.txt, w, * $+ yourword $+ *)) { commands }
new username: tidy_trax
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
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
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
Joined: May 2003
Posts: 2,265 |
i dont care thats what i use
new username: tidy_trax
|
|
|
|
Joined: Jan 2003
Posts: 27
Ameglian cow
|
OP
Ameglian cow
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
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
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
|
|
|
|
Joined: Dec 2002
Posts: 169
Vogon poet
|
Vogon poet
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> 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. 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.
|
|
|
|
Joined: Dec 2002
Posts: 169
Vogon poet
|
Vogon poet
Joined: Dec 2002
Posts: 169 |
I reread your original post. I think this alias might be your best bet: alias scantext {
if ($isid == $false) { echo $color(info) -esti * Scantext needs to be called as an identifier | return }
if ($0 < 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.
|
|
|
|
|