mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 580
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
Ok can someone please tell me what I am doing wrong here???

I have scripts that preserve the contents of channel and query windows... Channel windows are saving, query windows are not, but their code is almost the same!!!!

$sgroup = $server($server).group
$b16encode = Converts every character in a string to hexidecimal to avoid characters that can be in a nick, but not a filename. Look at /savequery and /savechans they are exactlly the same, except one uses $query and one uses $chan.

; These run in the disconnect event
alias savequery { var %Index 1 | while ($query(%Index) != $null) { .savebuf $query(%Index) $logdir $+ $querylogfile1($query(%Index)) | inc %Index } }

alias savechans { var %Index 1 | while ($chan(%Index) != $null) { .savebuf $chan(%Index) $logdir $+ $chanlogfile1($chan(%Index)) | inc %Index } }

alias querylogfile1 { return Query- $+ $b16encode($1) $+ - $+ $sgroup $+ .log }

alias chanlogfile1 { return Buffer- $+ $b16encode($1) $+ - $+ $sgroup $+ .log }

Thanks,
NaquadaServ

Last edited by Merlin; 26/12/02 06:01 PM.

NaquadaBomb
www.mirc-dll.com
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Code:

on *:DISCONNECT:{
  SaveQueries
  SaveChannels
}
;
alias SaveQueries {
  var %Index = 1
  while ($query(%Index)) {
    .savebuf $ifmatch $_QueryLogFile1($ifmatch)
    inc %Index 
  } 
}
;
alias SaveChannels {
  var %Index = 1
  while ($chan(%Index)) {
    .savebuf $ifmatch $_ChanLogFile1($ifmatch)
    inc %Index
  }
}
;
alias _QueryLogFile1 return $+($logdir,Query-,$B16Encode($1),-,$SGroup,.log)
;
alias _ChanLogFile1 return $+($logdir,Buffer-,$B16Encode($1),-,$SGroup,.log)
;
alias B16Encode {
  var %String, %Index = 1
  while ($mid($1,%Index,1)) {
    %String = $+(%String,$base($asc($ifmatch),10,16,2)))
    inc %Index
  }
  return %String
}
;
alias SGroup return $server($server).group

The above code is tested and works.

Changes:
  • Added the = between var and %Index
  • Removed the pointless != $null comparison in the while ( ) condition
  • Used $ifmatch instead of resolving the matching condition twice more
  • Renamed both log aliases to start with _ to avoid possible conflicts with $query and $chan resolving too soon
  • Moved $logdir down into the _*LogFile1 since is does not ever change
  • Switched $+ $+ $+ $+ to the cleaner-reading $+( , , , ) format
  • Cosmetic: Capitalized the first character of each word in the alias names and pluralised the Save* aliases
Hope this helps you find or solve your problem.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C

Link Copied to Clipboard