mIRC Homepage
Posted By: Jarder $read from txt file - 28/09/06 05:34 PM
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
Posted By: Scorpwanna Re: $read from txt file - 28/09/06 05:51 PM
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.
Posted By: Riamus2 Re: $read from txt file - 28/09/06 08:53 PM
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.
Posted By: DaveC Re: $read from txt file - 28/09/06 09:52 PM
Quote:
dcc send Riamus $1,000,000


$1= XXXX

dcc send Riamus XXXX,000,000

<snicker snicker> Hugs and kisses to ya!
Posted By: Riamus2 Re: $read from txt file - 28/09/06 10:39 PM
Lol, nice one. laugh
Posted By: Jarder Re: $read from txt file - 29/09/06 08:30 AM
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
Posted By: deegee Re: $read from txt file - 29/09/06 09:34 PM
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! }
© mIRC Discussion Forums