mIRC Home    About    Download    Register    News    Help

Topic Options
#160592 - 28/09/06 06:34 PM $read from txt file
Jarder Offline
Bowl of petunias

Registered: 28/09/06
Posts: 2
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

Top
#160593 - 28/09/06 06:51 PM Re: $read from txt file
Scorpwanna Offline
Fjord artisan

Registered: 20/09/03
Posts: 261
Loc: Arkansas, US
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.
_________________________
We don't just write the scripts, we put them to the test! (ScriptBusters)

Top
#160594 - 28/09/06 09:53 PM Re: $read from txt file
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#160595 - 28/09/06 10:52 PM Re: $read from txt file
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Quote:
dcc send Riamus $1,000,000


$1= XXXX

dcc send Riamus XXXX,000,000

<snicker snicker> Hugs and kisses to ya!

Top
#160596 - 28/09/06 11:39 PM Re: $read from txt file
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
Lol, nice one. laugh
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#160597 - 29/09/06 09:30 AM Re: $read from txt file
Jarder Offline
Bowl of petunias

Registered: 28/09/06
Posts: 2
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

Top
#160598 - 29/09/06 10:34 PM Re: $read from txt file
deegee Offline
Fjord artisan

Registered: 16/06/06
Posts: 508
Loc: Storage
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! }

Top