mIRC Home    About    Download    Register    News    Help

Print Thread
#160592 28/09/06 05:34 PM
J
Jarder
Jarder
J
Hi!
My problem is how to find the text from a specific line?

-----------------------
//echo $read(info.txt, s, mirc)

Scans the file info.txt for a line beginning with the word mirc and returns the text following the match value.
-----------------------
^ I'm trying to do this but I want only scan the specific line. (for example, only line 2). I don't want that this "s" scans the hole .txt until its find the word.

Is it possible to limit this "scanning"? Please help me. thx. smile

confused

#160593 28/09/06 05:51 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
s scans the beginning of a line for that word. meaning the first word of the line.
w scans a line for *text*

$read(file,s,text)

If you have a text file with lines:
mirc is a cool program
text is what i'm typing now

it would find "text"

$read(file,w,*what*)
If you have a text file with lines:
mirc is a cool program
text is what i'm typing now

it would find "what" on line 2

To scan a specific line just include it:

/help $read

$read(filename, [ntswrp], [matchtext], [N])

$read(filename, switches, text, N is a number) if you want to read a certain line, you include that line number, if you want to start on a line for a search you include that number.

#160594 28/09/06 08:53 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
If you know that what you want is always on a specific line, just read that line.

To read line 4 in filename.txt, you'd use:
$read(filename.txt,4)

You can put that into an IF statement if you want to see if a specific word is in there...

if (Riamus isin $read(MillionDollarWinners.txt,2)) { dcc send Riamus $1,000,000 }

Ok, ignore the humor in there... that would be true only if Riamus was in line 2 of that text file.

#160595 28/09/06 09:52 PM
D
DaveC
DaveC
D
Quote:
dcc send Riamus $1,000,000


$1= XXXX

dcc send Riamus XXXX,000,000

<snicker snicker> Hugs and kisses to ya!

#160596 28/09/06 10:39 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Lol, nice one. laugh

#160597 29/09/06 08:30 AM
J
Jarder
Jarder
J
I didn't get it work.. frown So what I mean is here:
This is a some kind of trivia game.
I have a text file which contains from answers and nicks.

answers.txt:
answer1 nick1
answer2 nick2
answer1 nick3
answer3 nick4
answer1 nick5
...

So with this: (!right answer1) I try to find the nicks who got the answer1.

on *:TEXT:!right *:#:{
set %correct1 $gettok $read(anwers.txt, s, $2)
msg $chan %correct1 You knew the answer!
}

So it will find the word answer1 and give me the nick from line1 (nick1). But how I can find those nick3 and nick5 who has got also right answers? The search will stop when it's find the first answer, but if there are more answers, how to find them all and get nicks from each one?

I hope you understand what I'm trying to say here.
grin

#160598 29/09/06 09:34 PM
Joined: Jun 2006
Posts: 506
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 506
Try this
Code:
on *:text:!right *:#:{
  filter -fk answers.txt _answers  $2- $+ *
  play # answers.tmp
  .remove answers.tmp
}
alias -l _answers { write answers.tmp  $gettok($1,2,32) You knew the answer! }


Link Copied to Clipboard