mIRC Home    About    Download    Register    News    Help

Print Thread
$read suggestion/example needed #23804 12/05/03 11:27 AM
Joined: Jan 2003
Posts: 96
J
Jesper Offline OP
Babel fish
OP Offline
Babel fish
J
Joined: Jan 2003
Posts: 96
How do I make $read read the last lines of a txt file?
like. I know how to get the last, but how to get the last 10 or 5 for that matter?


I need it in a alias event that echos the results to me.
eg.

alias readnews
;usage /readnews (number of lines to read but max 10)
echo -a .... this is where you can help me smile

Re: $read suggestion/example needed #23805 12/05/03 11:43 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
two ways
first u can use loadbuf: /loadbuf NUMBER-OF-LINES WINDOW file.txt
and the second:
alias readnews {
if ($1 <= 10) {
var %i = $calc($lines(file.txt) - $1 +1)
while (%i <= $lines(file.txt)) {
echo -a $read(file.txt,%i)
inc %i
}
}
}

Last edited by ScatMan; 12/05/03 11:51 AM.
Re: $read suggestion/example needed #23806 12/05/03 12:12 PM
Joined: Jan 2003
Posts: 96
J
Jesper Offline OP
Babel fish
OP Offline
Babel fish
J
Joined: Jan 2003
Posts: 96
uuh Scatman, "readnews 1" reads 2 lines, "readnews 2" reads 3 lines.. etc etc frown

Re: $read suggestion/example needed #23807 12/05/03 02:42 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
i'd edited my command, check the new one

Re: $read suggestion/example needed #23808 12/05/03 03:09 PM
Joined: Jan 2003
Posts: 96
J
Jesper Offline OP
Babel fish
OP Offline
Babel fish
J
Joined: Jan 2003
Posts: 96
Many thanks smile