mIRC Home    About    Download    Register    News    Help

Print Thread
#225748 08/09/10 08:29 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
looking to check a text file every 30 seconds and if the end line inside it has changed (or more accurately a new line added to it) to msg the line to the channel but also if more than 1 line has been added to message them too

timer for checking every so often to call an alias I assume?

edit: file has linux line endings not windows

Last edited by firefox; 08/09/10 08:29 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
One option is to have your timer call and alias that uses /loadbuf to load the new line(s) (the previous saved line number through $lines() ) to a custom window (you can hide the window if you want) and then /play that window.

Another option is to loop through and $read or $fread the lines from the previous saved line number until $lines() and msg them.

Both options should be easy enough to figure out. Take a try at it and if you need help, show what you tried and we can help you correct it. It's much better if you make the effort to script something rather than have others do it all for you. You'll learn it much better that way.


Invision Support
#Invision on irc.irchighway.net
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
ok thanks

so far I have this:
Code:
alias check {

  if (!$window(@check)) { /window -ke @check 0 0 850 400 }
  set %dlines $lines(1.txt) 
  /loadbuf $calc(%dlines - %lastdlines) -p @check 1.txt
  set %lastdlines %dlines
}
which seems to work in the window - but how to play it into the channel?

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Here's an idea.

I set the lines of text in the text file, then I check every 30 seconds to see if there are more lines in the text file. If there are I set the variable to the new line count and message the lines to the channel. I didn't test it, hope it works for you.

Code:
on *:start:{
  if (%1.txt) {
    set %dlines $lines(1.txt)
    timer1.txt 0 30 check
  }
}
alias check {
  if (!%dlines) set %dlines $lines(1.txt)
  if ($1 = on) timer1.txt 0 30 check
  elseif ($1 = off) timer1.txt off
  elseif (%dlines < $lines(1.txt)) {
    set %dlines $lines(1.txt)
    var %2 = $v2, %c_ = $calc(%2 - $v1), %cx_ = $calc(%2 - %c_)
    while ($read(1.txt,%cx_)) {
      msg %dchan : $v1
      inc %cx_
    }
  }
}
menu menubar {
  Check Text
  .$iif(%1.txt,$style(1)) on:check on
  .$iif(%1.txt,$style(1)) off:check off
  .-
  .$iif($chan,Set Channel):set %dchan $chan
}

Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
I'm going to avoid this topic for the time being...


Beware of MeStinkBAD! He knows more than he actually does!

Link Copied to Clipboard