mIRC Homepage
Posted By: extractor logging - 06/05/03 02:13 AM
is it possible to paste logfiles (not from irc) in a irc chat window as they update?. someone told me it would be a script to do it and it would be something like this as a base -

if (%currentread == %lastread) { halt }
else { $read test.txt }

i wouldn't have a clue about how to complete the script, could someone help me out. or perhaps direct me to a irc script that pastes log files into a chat window as one of its functions, thanks
Posted By: Nimue Re: logging - 06/05/03 03:05 AM
Code:
alias pastelines { 
  var %i = $calc(%lastread +1)
  if $read([color:red]file.txt[/color],%i) {
    .play -f $+ %i [color:blue]#channelname[/color] [color:red]file.txt[/color] 2000
    set %lastread $lines([color:red]file.txt[/color])
  }
}
You should change file.txt to the actual file, and #channelname to the channelname you want to 'paste' to.
Also, if you type /set %lastread <insert the line # you last pasted> (without the < & >)you can avoid catching anything before that line #.
Posted By: extractor Re: logging - 06/05/03 03:36 AM
ok i tried that in norm irc and in a script by pressing alt+r and pasting in there and editing the file names and channel. but neither of them worked. did u test that script beforehand?
when i did the file name i did the full link (eg. D:\games\blahblah.txt)
and the channel name #blah
i must have done something wrong, can you help please, thanks
Posted By: Nimue Re: logging - 06/05/03 08:07 AM
I have tested and it does work, both with and without the variable preset.
Put "quote marks" around the path & filename, "D:\games\blahblah.txt"
Make sure the code has been pasted into the same 7 lines and not all in one long line.

I also assume that you do know have to call it via a command, /pastelines , which you can then automate with a timer. smile
Posted By: extractor Re: logging - 06/05/03 10:15 AM
ahh yeah /pastelines worked, but it said -

* /if: invalid format (line 3, script.ini)

my line 3 looks like -

if $read"D:\games\blahblah.txt,%i" {

i think ive made a mistake with the position of the " and " or closing and opening brackets, what should it look like?
Posted By: Nimue Re: logging - 06/05/03 10:19 AM
You have lost the parentheses.
if $read("D:\games\blahblah.txt",%i) {
Posted By: extractor Re: logging - 06/05/03 10:44 AM
sweet i got it to work, however no i dont know how to automate /pastelines . teach me o great one smile

i can see u live on sunshine coast, i live in brisbane just near you laugh
Posted By: Nimue Re: logging - 06/05/03 10:59 AM
OK, to check it every 10 minutes.
/timerplines 0 600 pastelines
Broken down into it's parts,
/timerplines - is the command to start the timer, and give it a name (plines)
0 means repeat forever, if you would use 10 in its place the timer would fire 10 times.
600 is the delay (in seconds) between each repetition.
pastelines is the command to perform.
If you want to automatically start the process when you join #channel

Code:
on me:*:join:[color:darkblue]#channel[/color]:{
  [color:blue].timerplines[/color] [color:red]0[/color] [color:bluee]600[/color] [color:orange]pastelines[/color]  
}
The .dot in front of the timer there, keeps mirc from displaying * Timer plines activated
Posted By: extractor Re: logging - 06/05/03 11:16 AM
well that all worked, but it showed all the past logs but none current, it says -
/if: '06' unknown operator (line 3, script.ini)
Posted By: Nimue Re: logging - 06/05/03 11:21 AM
Make sure line 3 looks exactly the same as this.
if $read("D:\games\blahblah.txt",%i) {
Posted By: extractor Re: logging - 06/05/03 11:24 AM
yeah it is, but its not really d:\games\blahblah.txt i just said that as example, but that file name works, but my proper one doesn't for some stupid reason. if i could get it to duplicate the logs into another file that would work, but i suppose thats another issue. and i dont think i can just edit eh script and tell it to go to a different directory either, but ill have a look
Posted By: Nimue Re: logging - 06/05/03 11:26 AM
Paste in the code exactly as you have it. There is nothing wrong with that line. smile
Posted By: extractor Re: logging - 06/05/03 11:28 AM
ok ill let u see what game im playing :P

if $read("D:\games\Diablo II\d2jsp\scripts\output\qwqalog.txt",%i) {

all on 1 line
Posted By: Nimue Re: logging - 06/05/03 11:31 AM
I don't care what games you play. laugh

I meant the whole code block not just the one line. wink
Posted By: extractor Re: logging - 06/05/03 11:32 AM
alias pastelines {
var %i = $calc(%lastread +1)
if $read("D:\games\Diablo II\d2jsp\scripts\output\qwqalog.txt",%i) {
.play -f $+ %i #testggg ("D:\games\Diablo II\d2jsp\scripts\output\qwqalog.txt") 2000
set %lastread $lines("D:\games\Diablo II\d2jsp\scripts\output\qwqalog.txt")
}
}

on me:*:join:#channel:{ .timerplines 0 30 pastelines }

--

but i dont see how the other lines have anything to do with it, it says line 3
Posted By: Nimue Re: logging - 06/05/03 11:44 AM
Well why I wanted to see the other lines, is because there is nothing wrong with line3, and sometimes a previous line can affect an otherwise perfectly good line.
I don't see anything wrong with any line there though, try moving it to a new file or something.
Posted By: Collective Re: logging - 06/05/03 11:52 AM
This is a sort-of-bug that can happen with $read, normally it can be fixed by using the n switch in $read, i.e.

if $read("D:\games\Diablo II\d2jsp\scripts\output\qwqalog.txt",n,%i) {
Posted By: extractor Re: logging - 06/05/03 11:52 AM
can u use a shortcut to the file?
Posted By: extractor Re: logging - 06/05/03 12:04 PM
sweet it all works now, it pastes new lines into irc, thanks so much for helping me out. ill have to go off and learn programming/scripting myself now smile
Posted By: Nimue Re: logging - 06/05/03 12:04 PM
Try Collectives suggestion, and this
if $read("D:\games\Diablo II\d2jsp\scripts\output\qwqalog.txt",n,%i) != $null {
Posted By: extractor Re: logging - 06/05/03 12:09 PM
the ,n did the trick
Posted By: Collective Re: logging - 06/05/03 12:10 PM
Just for the record: The n switch has another advantage that is expecially useful when reading from text files that vary alot - if the line you are reading has a "|" symbol in it will execute whatever text follows the | as a command, if you use the n switch for $read this never happens, so it is best to use the n switch. This doesn't always happen though, which makes me wonder if it is a bug...
Posted By: extractor Re: logging - 06/05/03 01:12 PM
you are exactly right, every line it pastes in has a | in it
Posted By: Nimue Re: logging - 06/05/03 01:56 PM
Collective: Yes, very true, and thanks much for the input. smile

extractor: Sorry about messing you around with my brain fart. :tongue:
Posted By: qwerty Re: logging - 06/05/03 03:44 PM
What doesn't always happen? Do you mean that sometimes the part after the | is executed as a command, even if you specify the n switch? If it's that, do you have any example handy that reproduces it?
Posted By: Collective Re: logging - 06/05/03 03:47 PM
No, I meant that sometimes without the n switch it doesn't execute the command and sometimes it does. Next time I'll word my posts better smile
Posted By: extractor Re: logging - 06/05/03 10:26 PM
nah that cool, u confused me with your broad knowledge of scripting. smile
© mIRC Discussion Forums