The main problem is that your window might get cleared, or culled, due to another script that messes with it directly. If that is the case, rudimentary debugging won't help.

However, that would probably be rare and it's more likely the result of some manner of event.

Below is a chunk of code that enables standard debug logging (server messages, sent and received) as well as adding debug logs for most events that wouldn't be caught by the debug logging.

In mIRC, press ctrl+r to open the remote scripts window, go to File, new..., then copy/paste the entire thing below:
Code:
; set to $false if you do not want a pop-up window asking you for feedback to appear
; set to $true to allow you to provide additional information in the log when the line count for a window decreases
; for example, you could enter "I was messing around with NNscript"
alias feedback { return $true }

alias checklines {
  ; make sure we still want to check things
  if ($window(@debug) == $null) { .timerchecklines off | .disable #debugevents }

  ; loop over all windows
  var %numwindows = $window(*,0)
  var %i = 1
  while (%i <= %numwindows) {
    var %window = $window(*,%i)
    var %windowlines = $line(%window,0)
    var %windowindex = $findtok(%window.cache,%window,44)
    ; if we have previously recorded this window
    if (%windowindex) {
      ; and thus its number of lines
      var %windowlines.old = $gettok(%windowlines.cache,%windowindex,44)

      ; check if it decreased, and log it if it did
      if (%windowlines < %windowlines.old) {
        echo -t @debug ?DEBUG -> WINDOW LINE COUNT DECREASED -> window: %window line.old: %windowlines.old line.new: %windowlines
        if ($feedback) { beep | echo -t @debug ?DEBUG -> FEEDBACK -> $?="feedback:" }
      }

      ; update the number of lines for the window in the cache if it's different either way
      if (%windowlines != %windowlines.old) {
        set %windowlines.cache $puttok(%windowlines.cache,%windowlines,%windowindex,44)
      }
    }
    else {
      ; otherwise this is a newly opened window and we can just add its results
      set %window.cache $addtok(%window.cache,%window,44)
      set %windowlines.cache $instok(%windowlines.cache,%windowlines,0,44)
    }
    inc %i
  }

  ; Now let's loop over our cache, and cull any cache results for which we no longer have an open window anyway
  ; ( This could partially be dealt with in on:close )
  var %i = $numtok(%window.cache,44)
  while (%i >= 1) {
    var %window = $gettok(%window.cache,%i,44)
    if ($window(%window) == $null) {
      set %window.cache $deltok(%window.cache,%i,44)
      set %windowlines.cache $deltok(%windowlines.cache,%i,44)
    }
    dec %i
  }
}

alias startdebug {
  .enable #debugevents
  echo -s ?DEBUG -> Debug info logging for window line count started
  echo -s ?DEBUG -> To disable, simply close the @debug window
  .debug -t @debug
  .log on @debug -f @debug.log
  .timerchecklines -o 0 1 /checklines
}

alias debugevent {
  if ($window(@debug)) { echo -t @debug ?EVENT -> on: $+ $event $iif($1,->) $1- }
}

on *:start:{
  unset %window.cache
  unset %windowlines.cache
  /startdebug
  /debugevent
}

#debugevents off
on *:active:*:{ debugevent lactivecid: $lactivecid activecid: $activecid lactive: $lactive active: $active }
on *:appactive: { debugevent appactive: $appactive }
on *:chat:*:{ debugevent <msg>: $1- }
on *:close:*:{ debugevent target: $target }
on *:connect:{ debugevent network: $network server: $server }
on *:connectfail:{ debugevent <reason>: $1- }
on *:dccserver:chat:{ debugevent chat }
on *:dccserver:send:{ debugevent send }
on *:dccserver:fserve:{ debugevent fserve }
on *:disconnect:{ debugevent network: $network server: $server }
on *:dns:{
  var %n = $dns(0)
  while (%n > 0) {
    debugevent n: %n dns: $dns(%n) nick: $dns(%n).nick addr: $dns(%n).addr ip: $dns(%n).ip
    dec %n
  }
}
on *:exit:{ debugevent }
on *:filercvd:*:{ debugevent filename: $filename nick:$nick }
on *:filesent:*:{ debugevent filename: $filename nick:$nick }
on *:getfail:*:{ debugevent filename: $filename nick:$nick }
on *:input:*:{ debugevent target: $target <input>: $1- }
on *:load:{ debugevent }
on ^*:logon:*:{ debugevent network: $network server: $server }
on *:logon:*:{ debugevent network: $network server: $server }
on *:midiend:{ debugevent }
on *:mp3end:{ debugevent }
on *:nosound:{ debugevent filename: $filename }
on *:open:*:*:{ debugevent target: $target }
on *:playend:*:*:{ debugevent filename: $filename }
on *:sendfail:*:{ debugevent filename: $filename nick:$nick }
on *:serv:*:{ debugevent <msg>: $1- }
on *:tabcomp:*:{ debugevent target: $target <input>: $1- }
on *:wavend:{ debugevent }
#debugevents end

on *:unload:{
  debugevent
  unset %window.cache
  unset %windowlines.cache
}

( code is preliminary, may have bugs )

Then press the OK button.
mIRC will warn you that there are initialization events in it, just accept those (you can see in the code for 'on:start' what they do).

From that point on, a bunch of logging will occur to the @debug window. Just leave that running in the background. If at any point the number of lines in a window decreases, the computer will beep (or play the default beep sound) and you'll get a little dialog asking you for feedback. I.e. if you pressed some button, you can enter that, and it will be included in the debug output.

Example output:
Code:
[03:37:11] ?DEBUG -> WINDOW LINE COUNT DECREASED -> window: Status Window line.old: 8 line.new: 0
[03:37:12] ?EVENT -> on:appactive -> appactive: $true
[03:37:14] ?DEBUG -> FEEDBACK -> I typed /clear, then alt-tabbed to the mIRC forums


The debug log is logged to a file as well, in mIRC's application data folder, 'debug.log'.

If you don't want the feedback popup to occur, you can disable it near the top of the script.

Last edited by Steeeve; 17/02/12 02:42 AM.