mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2005
Posts: 3
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2005
Posts: 3
hey there
Here my question:
I have a textfile called test.txt. I want to read the 2nd line of it (or the hole text) and let my script search for a word in it, and compare this word with a word given. I have 26 diffrent words that are given. And when the script has found one of these words (there is all the time only one of these words in that .txt file), it will give out the result. Here is what I got but it never worked confused


Code:
 alias textsearch {

var %test =  $read(test.txt,npts,2)


  if $matchtok(%test, *testword*,0 ,32) = 1) {
    echo I have found the testword in test.txt
  }
 if $matchtok(%test, *testwordtwo*,0 ,32) = 1) {
    echo I have found the testwordtwo in test.txt
  }
...
} 


I know the 32 in $matchtok is correct there are spaces between each word.

Thanks for help.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Start out with this correction and see if it works after it.

var %test = $read(test.txt,npts,2)
replace with
var %test = $read(test.txt,npt,2)


The s is for search for matching start of line, which you do not need.

Joined: Jun 2005
Posts: 3
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2005
Posts: 3
No that didnt help...
I think that I cant use the var %test in
Code:
    if $matchtok(%test, *testword*,0 ,32) = 1)  { 


Anyone an Idea how can i solve that?
I also tried
Code:
   if $istok(%test, *testword*, 32) = $true) { 

But nothing frown

How can make my $matchtok understand a line from a .txt????

Last edited by tetrahydroc; 26/06/05 09:52 AM.
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
No that didnt help...

Yes it did, it just didnt end your problems.

The bigest problem is i think you need to make it clear what you want as a final result.

(1) Are you ONLY trying to detect one of a set number of words being present in line 2 of TEXT.TXT, or the whole file?
(2) And is it ONLY the exact word? ie: is if TEXT.TXT has APPLETREE in it and the word your looking for is LET then it is NOT found.





Here my question:
I have a textfile called test.txt. I want to read the 2nd line of it (or the hole text) and let my script search for a word in it, and compare this word with a word given. I have 26 diffrent words that are given. And when the script has found one of these words (there is all the time only one of these words in that .txt file), it will give out the result. Here is what I got but it never worked confused

(1) LINE2 (2) EXACT
[code]
alias textsearch {
var %test = $read(test.txt,nt,2)
if ($istok(%test,testword1,32)) { echo I have found the testword1 in test.txt line 2 }
if ($istok(%test,testword2,32)) { echo I have found the testword2 in test.txt line 2 }
...
}
[code]

(1) LINE2 (2) ANY
[code]
alias textsearch {
var %test = $read(test.txt,nt,2)
if (testword1 isin %text) { echo I have found the testword1 in test.txt line 2 }
if (testword2 isin %text) { echo I have found the testword2 in test.txt line 2 }
...
}
[code]

(1) ALLFILE (2) EXACT
[code]
alias textsearch {
if ( ($read(test.txt,ntw,* testword1 *)) || ($read(test.txt,ntw,testword1 *)) || ($read(test.txt,ntw,* testword1)) || ($read(test.txt,ntw,testword1)) ) { echo I have found the testword1 in test.txt }
if ( ($read(test.txt,ntw,* testword2 *)) || ($read(test.txt,ntw,testword2 *)) || ($read(test.txt,ntw,* testword2)) || ($read(test.txt,ntw,testword2)) ) { echo I have found the testword2 in test.txt }
...
}
[code]

(1) ALLFILE (2) ANY
[code]
alias textsearch {
if ( ($read(test.txt,ntw,*testword1*)) { echo I have found the testword1 in test.txt }
if ( ($read(test.txt,ntw,*testword2*)) { echo I have found the testword2 in test.txt }
...
}
[code]
.
.
.
.
.
ATTN: REGEX coders
can someone replace this please
if ( ($read(test.txt,ntw,* testword1 *)) || ($read(test.txt,ntw,testword1 *)) || ($read(test.txt,ntw,* testword1)) || ($read(test.txt,ntw,testword1)) ) { echo I have found the testword1 in test.txt }

Want to locate the word "textword1" which might be anyword inside TEXT.TXT but it must be a word, ie: NOT LET in APPLETREE
I think i found it using the word boundry control but im not confident on it.

Joined: Jun 2005
Posts: 3
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2005
Posts: 3
I looked for (1) ALLFILE (2) EXACT and thanks a lot it works!
I treid everything but not the $isin which solved my problem...
many thx


Link Copied to Clipboard