aIRC — File Browser

aIRCv0.8.69 / aIRCv0.8.69 / script / base.mrc

base.mrc — 24.73 KB — Download this file

;/**********************************************************************
; *
; * aIRC
; * Preprocessing and Start Routines
; *
; **********************************************************************/

ON *:EXIT:{
  info.a Exiting...
  _hook.call onexit
}
ON ^*:NOTIFY:{
  unset %++* %~^event.*
  %†connected = 1
}
ON ^*:UNOTIFY:{
  unset %++* %~^event.*
  %†connected = 1
}
ON ^*:ACTION:*:*:{ _remotevars }
ON ^*:BAN:#:{
  _remotevars
  unset %+onban.*
  %+onban.num = $ialchan($banmask,$chan,0)
  if ($_ialnicks($banmask,$chan,5,$null) != $null) { %+onban.nicks = $ifmatch }
}
ON *:CTCPREPLY:*:{
  _remotevars
  if ($nick == $me) && (airc_* iswm $1) { halt }
}
ON ^*:DEOP:#:{ _remotevars }
ON ^*:DEOWNER:#:{ _remotevars }
ON ^*:DEVOICE:#:{ _remotevars }
ON ^*:INVITE:#:{ _remotevars }
ON ^*:JOIN:#:{
  if ($nick == $me) && ($line(#,0) == 0) && ($_getsetup(script,_logjoin)) && ($_logfile($chan) != $null) { loadbuf 100 -p $chan " $+ $ifmatch $+ " }
  _remotevars
  unset %+clones.*
  %+clones.immunes = $_getclonimmunes($chan)
  if ($istok(%+clones.immunes,$site,32) == $false) && ($_getclones($fulladdress,$chan,0,$null).number) {
    %+clones.num = $ifmatch
    if ($_getsetup(script,_clonesinjoinline)) && ($_getclones($fulladdress,$chan,5,$nick) != $null) {
      %+clones.nicks = $ifmatch
      ^addcomment2event $^_join.clones(%+clones.num,%++maskclon,%+clones.nicks)
    }
  }
}
ON ^*:KICK:#:{ _remotevars }
ON ^*:MODE:#:{ _remotevars }
ON ^*:NICK:{ _remotevars }
ON ^*:NOTICE:*:*:{ _remotevars }
ON ^*:OP:#:{ _remotevars }

ON ^*:OPEN:*:{ _remotevars }
ON *:OPEN:*:{ _remotevars }

ON ^*:OWNER:#:{ _remotevars }
ON ^*:PART:#:{ _remotevars }
ON ^*:QUIT:{
  _remotevars
  %++isnetsplit = $_isnetsplit($1-)
}
ON ^*:SERVERMODE:#:{ _remotevars }
ON ^*:SNOTICE:*:{ _remotevars }
ON ^*:RAWMODE:#:{ _remotevars }
ON ^*:TEXT:*:*:{ _remotevars }
ON ^*:TOPIC:#:{ _remotevars }
ON ^*:UNBAN:#:{
  _remotevars
  unset %+onunban.*
  %+onunban.num = $ialchan($banmask,$chan,0)
  if ($_ialnicks($banmask,$chan,5,$null) != $null) { %+onunban.nicks = $ifmatch }
}
ON ^*:USERMODE:{ _remotevars }
ON ^*:VOICE:#:{ _remotevars }
ON ^*:WALLOPS:*:{ _remotevars }
CTCP *:*:*:{
  _remotevars
  _onctcp $1-
}
raw 352:*:{
  %::fromserver = $nick
  %::me = $me
  if (* isin $7) { _ircoplist.add $6 }
}
raw 4:*:{
  %::fromserver = $nick
  %::me = $me
  .timer -mo 1 0 _start
}
raw *:*:{
  %::fromserver = $nick
  %::me = $me
}
alias -l _remotevars {
  unset %++* %::* %~^event.*
  %†connected = 1
  if ($event == nick) {
    var %fa = $newnick $+ ! $+ $address
    if ($_finduser(%fa) != $null) {
      %++handle = $ifmatch
      %++flags  = $_nickflags(%++handle,$chan)
    }
  }
  else {
    if ($_finduser($fulladdress) != $null) {
      %++handle = $ifmatch
      %++flags = $_nickflags(%++handle,$chan)
      if ($chan != $null) {
        .timer -o 1 0 _setuserfield %++handle laston $ctime $chan
        .timer -o 1 0 _setuserfield %++handle laston. $+ $chan $ctime
      }
    }
    if ($opnick != $null) {
      %++fulladdress2 = $_address($opnick,5)
      if ($_finduser(%++fulladdress2) != $null) {
        %++handle2 = $ifmatch
        %++flags2 = $_nickflags(%++handle2,$chan)
        if ($chan != $null) {
          .timer -o 1 0 _setuserfield %++handle2 laston $ctime $chan
          .timer -o 1 0 _setuserfield %++handle2 laston. $+ $chan $ctime
        }
      }
      %++service2  = $iif($_iservice(%++fulladdress2),1,0)
      %++maskclon2 = $_mask(%++fulladdress2,%_maskclon)
    }
  }
  %++service = $iif($_iservice($fulladdress),1,0)
  %++maskclon = $_mask($fulladdress,%_maskclon)

  if ($group(#_airctexthemes) == on) {
    %::ircnum      = 0
    %::me          = $me
    %::nick        = $nick
    %::address     = $address
    %::chan        = $chan
    %::fulladdress = $fulladdress
    %::site        = $site
    %::knick       = $knick
    %::newnick     = $newnick
    %::handle      = %++handle
    %::userflags   = %++flags
    %::target      = $target
  }
  if ($timer(MAINTIMER) == $null) { .timerMAINTIMER -o 0 1 _maintimer }
}

ON *:LOAD:{ _oninstall }
ON *:START:{
  _onstart
  _remove addons\custom_r.mrc
  if ($_getsetup(script,_session) == 1) { cpanel }
  if (0) { .checkver }
}
alias _oninstall {
  if ($_mircvercheck) { return }
  var %i = 0
  mkdir usr\
  mkdir usr\default\
  timers off
  unsetall
  flush
  identd on airc
  while ($window(0)) { close -@ $window(1) }
  while ($dialog(0)) { dialog -x $dialog(1) }
  while ($alias(0)) {
    .unload -a " $+ $alias(1) $+ "
    if ($alias(0) <= 1) { inc %i }
    if (%i > 2) { break }
  }
  %i = 0
  while ($script(0)) {
    if ($nopath($script(1)) != $nopath($script)) { .unload -rs " $+ $script(1) $+ " }
    elseif ($nopath($script(2)) != $nopath($script)) { .unload -rs " $+ $script(2) $+ " }
    if ($script(0) <= 1) { inc %i }
    if (%i > 2) { break }
  }
  save -ru usr\default\users.mrc
  save -rv usr\default\vars.mrc
  if ($isfile(remote.ini)) { remove remote.ini }
  if ($isfile(aliases.ini)) { remove aliases.ini }
  if ($isfile(popups.ini)) { remove popups.ini }
  if ($isfile(script.ini)) { remove script.ini }
  if ($event != load) { _onstart }
}
alias _mircvercheck {
  unset %exit
  if ($bits != 32) { %exit = mIRC $+ $bits bits not supported. $crlf Go to http://www.mirc.co.uk/ and download a 32bits mIRC. }
  elseif ($version != 5.82) { %exit = aIRC $_vers needs mIRC32 v5.82. $crlf You are using mIRC v $+ $version $+ . }
  if (%exit) {
    _exit $?!=" [ %exit ] "
    return 1
  }
  return 0
}
alias _onstart {
  var %ticks,%pbaronstart = $_readini($_mainini,main,pbaronstart)
  if ($lock(dll)) { %pbaronstart = 0 }
  elseif ($1 != $null) { %pbaronstart = 1 }

  %ticks = $ticks

  if ($_mircvercheck) { return }

  var %chanmodes = %.chanmodes,%lag.current = %.lag.current,%maxkicks = %.maxkicks,%maxmodes = %.maxmodes,%myaddress = %.myaddress,%netbots = %.netbots,%network = %.network,%serversion = %.serversion,%services = %.services,%usermodes = %.usermodes,%connected = %†connected

  .disable #_* #~*
  unset %.* %_* %†* %~*

  if (%pbaronstart) { _miniprogress.init $1 }
  else { _miniprogress.close }
  _miniprogress 0 Verifying script files/dirs...

  mkdir usr\
  mkdir usr\default\
  _scriptfiles.load -apr

  if ($result) {
    echo $colour(ctcp) -eist *** ERROR: Files missing/corrupted... Please reinstall. Exiting...
    .timer -o 1 3 _exit
    halt
  }

  ;;;;; temp:
  _remove addons/ftp.help
  _remove addons/xdcc.help
  _remove script/theme.mrc
  var %u&r = script\sstatus.mrc script\userhost.mrc script\portscan.mrc script\seen.mrc script\nickomp.mrc script\dtwindow.mrc addons\fserve.mrc script\lag.mrc script\ircop.mrc script\hooks.mrc script\jokes.mrc script\tip.mrc script\fonts.mrc script\about.mrc script\tascii.mrc script\aircvers.mrc script\sockets.mrc script\logs.mrc script\textwin.mrc script\binds.mrc script\dccping.mrc script\ipchat.mrc script\ident.mrc script\notify.mrc script\idle.mrc script\netsplit.mrc script\fjoin.mrc script\orignick.mrc,%i = $numtok(%u&r,32),%f
  while (%i) {
    %f = $mircdir $+ $gettok(%u&r,%i,32)
    if ($script(%f)) { unload -rs " $+ %f $+ " }
    if ($isfile(%f)) { remove " $+ %f $+ " }
    dec %i
  }
  if ($alias(text.scheme)) {
    var %tmp = " $+ $ifmatch $+ "
    unload -a %tmp
    remove %tmp
  }

  if ($alias(aliases.ini)) && ($isfile($alias(aliases.ini)) == $false) { .unload -a " $+ $alias(aliases.ini) $+ " }
  if ($script(script.ini)) && ($isfile($script(script.ini)) == $false) { .unload -rs " $+ $script(script.ini) $+ " }
  .timer_reloadbasefile -o 1 0 _reloadbasefile

  _services.unload
  _start.uvfiles
  _start.customfiles
  %†connected = $iif($server,1,0)
  _setusrdir
  _loadhashmainsetup
  _start.dirs
  var %mainini = $_mainini,%from = $mircdir $+ etc\profile,%to = $mircdir $+ $_usrdir,%tmp
  _miniprogress 37
  %tmp = $_xcopy(%from,%to,*,l)
  _loadhashmainsetup

  _miniprogress 40
  _upgrading
  _loadhashmainsetup
  _setsetup script _scriptversion $_aircvernum

  _miniprogress 45 Performing DDE routines...
  _dde.newID

  if ($_getsetup(script,_aircdebug)) { _quickloadall }
  else {
    _miniprogress 72 Unloading unnecesary files...
    _quickunloadall
  }

  _miniprogress 75 Checking addons...

  _start.addons

  _miniprogress 90 Loading setup...

  _loadingsetuponstart

  if ($server) && (%connected) {
    %.chanmodes = %chanmodes
    %.lag.current = %lag.current
    %.maxkicks = %maxkicks
    %.maxmodes = %maxmodes
    %.myaddress = %myaddress
    %.netbots = %netbots
    %.network = %network
    %.serversion = %serversion
    %.services = %services
    %.usermodes = %usermodes
    %†connected = %†connected
  }

  _miniprogress 100 Completed!

  _warnmirclock
  _mOTFv.Load
  if ($server) {
    _mOTFv.Mark
    _mOTFv.SetVersion $_aircad(+)
  }
  ^start $calc(($ticks - %ticks) / 1000)
}
alias _miniprogress.init {
  var %win = @.miniprogress,%w = 130,%h = 58,%text = $iif(r isin $1,Rehash,Startup),%font = Tahoma,%fs = 14
  if ($window(%win) == $null) { window -fhkop +fL %win $calc(($window(-1).w - %w) / 2) $calc(($window(-1).h - %h) / 2) %w %h %win }
  window -a %win
  drawrect -fnr %win $rgb(face) 1 0 0 %w %h
  drawtext -nor %win $rgb(text) %font %fs $calc((%w - $width(%text,%font,%fs,1,0)) / 2) 6 %text
  drawrect -nr %win $rgb(text) 1 14 27 102 4
  drawrect -fnr %win $rgb(hilight) 1 15 28 100 2
  drawdot %win
  .timerCLOSEWIN@MINIPROGRESS -o 1 0 window -c %win
}
alias _miniprogress {
  var %win = @.miniprogress,%title = $window(%win).title,%time,%w = 130,%h = 58,%font = Tahoma,%fs = 12
  if ($window(%win) == $null) || ($1 !isnum) || ($1 < 0) { return }
  if ($1 >= 100) {
    window -c %win
    return
  }
  if ($getdot(%win,10,10) != $rgb(face)) { _miniprogress.init }
  drawrect -fnr %win $rgb(hilight) 1 15 28 100 2
  drawrect -finr %win 0 0 15 28 $round($1,0) 2
  if ($2- != $null) {
    drawrect -fnr %win $rgb(face) 1 0 37 %w %h
    drawtext -nr %win $rgb(text) %font %fs $calc((%w - $width($2-,%font,%fs,0,0)) / 2) 39 $2-
  }
  drawdot %win
}
alias _miniprogress.close {
  if ($window(@.miniprogress)) { close -@ @.miniprogress }
}
alias _warnmirclock {
  var %z = send get chat fserve run dll channels,%i = 1,%n = $numtok(%z,32),%t,%locked
  while (%i <= %n) {
    %t = $gettok(%z,%i,32)
    if ($lock(%t)) { %locked = $addtok(%locked,%t,32) }
    inc %i
  }
  if (%locked != $null) { warning mIRC has $iif($numtok(%locked,32) == 1,this feature,these features) locked: %locked $+ . Press ALT+O, go to General/Lock and uncheck $iif($numtok(%locked,32) == 1,it,them) $+ . }
}
alias upgrade {
  error.a The HOT Upgrade feature have been disabled. You must restart the script to upgrade.
  var %t = 0
  if ($nopath($isalias(_yesno).fname) == questions.mrc) { %t = $_yesno(1,Upgrade script [/upgrade],0,Reload script files and rehash?) }
  else { %t = $?!="Reload script files and rehash?" }
  if (%t) {
    _scriptfiles.load -aprfm
    if ($result) {
      echo $colour(ctcp) -eist *** ERROR: Files missing/corrupted... Please reinstall. Exiting...
      .timer -o 1 3 _exit
      halt
    }
    _onstart r
  }
}
alias rehash {
  var %t = 0
  if ($nopath($isalias(_yesno).fname) == questions.mrc) { %t = $_yesno(1,Rehash script [/rehash],0,Rehash script?) }
  else { %t = $?!="Rehash script?" }
  if (%t) { _onstart r }
}
alias _upgrading {
  .load -a script/_upgrading.mrc
  _upgrading.doit
  .unload -a script/_upgrading.mrc
}
alias _getusrdir {
  if ($nofile($mircini) != $mircdir) { return $gettok($ifmatch,-1,$asc(\)) }
  else { return default }
}
alias _setusrdir { %†usrdir = $_getusrdir }
alias _start.uvfiles {
  var %dir = $mircdir $+ usr\ $+ $_getusrdir $+ \,%uf = %dir $+ users.mrc,%vf = %dir $+ vars.mrc,%tf = %dir $+ text.scheme,%sf = %dir $+ sstatus.mrc
  if ($isfile(%tf) == $false) { write -c " $+ %tf $+ " }
  if ($isfile(%sf) == $false) { write -c " $+ %sf $+ " }
  if ($script(mierda.mrc)) {  }
  else { .load -rs8 addons\mierda.mrc }
  if ($script(%tf)) { .reload -rs9 " $+ %tf $+ " }
  else { .load -rs9 " $+ %tf $+ " }
  if ($script(%sf)) { .reload -rs10 " $+ %sf $+ " }
  else { .load -rs10 " $+ %sf $+ " }
  .load -ru " $+ $_chfile(%uf) $+ "
  .load -rv " $+ $_chfile(%vf) $+ "
}
alias _start.customfiles {
  var %dir = $mircdirusr\ $+ $_getusrdir $+ \,%ca = %dir $+ custom_a.mrc,%cr = %dir $+ custom_r.mrc
  if ($alias($mircdirscript\custom_a.mrc))  { .unload -a script\custom_a.mrc }
  if ($script($mircdirscript\custom_r.mrc)) { .unload -rs script\custom_r.mrc }
  if ($isfile(%ca) == $false) {
    if ($isfile(script\custom_a.mrc)) { .copy -o "script\custom_a.mrc" " $+ %ca $+ " }
    else { write -c " $+ %ca $+ " ; Add your aliases here... }
  }
  if ($isfile(%cr) == $false) {
    if ($isfile(script\custom_r.mrc)) { .copy -o "script\custom_r.mrc" " $+ %cr $+ " }
    else { write -c " $+ %cr $+ " ; Add your remotes here... }
  }
  .load -a " $+ %ca $+ "
  if ($script(%cr)) { .reload -rs2 " $+ %cr $+ " }
  else { .load -rs9 " $+ %cr $+ " }
}
ON *:CONNECT:{
  unset %c.nickhost.* %c.nickhosts.userhost
  %†connected = 1
  _orderemotefiles
  .disable #~*
  _start
  _onconnect.init-server
  _mOTFv.Mark
  _mOTFv.SetVersion
}
ON *:DISCONNECT:{
  %†connected = 0
  _orderemotefiles
  _services.unload
  unset %c.nickhost.* %c.nickhosts.userhost %.* %c.reial.c
  _start
  _tnick.reset
}
alias _tmpdir { return etc\tmp\ $+ $ddename $+ \ $+ $1- }
alias _tmpfile { return etc\tmp\ $+ $ddename $+ \ $+ $_randstring(8) $+ . $+ $iif($1 != $null,$1,tmp) }
alias _dde.newID {
  .ddeserver off
  _dde.checkIDs
  var %n,%t,%ids = $_readini($_mainini,main,aIRCIDs)
  while (1) {
    %t = aIRC $+ %n
    if ($istok(%ids,%t,32)) || ($isdde(%t)) { inc %n }
    else { break }
  }
  _miniprogress 70
  .ddeserver on %t
  writeini " $+ $_mainini $+ " main aIRCIDs $addtok(%ids,%t,32)
  .mkdir $_tmpdir
  .mkdir $_tmpdir(clones)
}
alias _dde.checkIDs {
  var %t,%p,%ids = $_readini($_mainini,main,aIRCIDs),%i = $numtok(%ids,32),%tdde,%isactivedde = $false
  while (%i) {
    %t = $gettok(%ids,%i,32)
    if (%t != $null) {
      var %tdde,%isactivedde = $isdde(%t)
      if (%isactivedde) { %tdde = $dde %t exename "" }
      if (%isactivedde == $false) || (%tdde != $mircexe) {
        %ids = $remtok(%ids,%t,32)
        ._rmdir $mircdir $+ etc\tmp\ $+ %t
      }
    }
    dec %i
  }
  if (%ids != $null) { writeini " $+ $_mainini $+ " main aIRCIDs %ids }
  else { remini " $+ $_mainini $+ " main aIRCIDs %ids }
  _miniprogress 60
}
alias lang {
  var %curr = $_getlang
  if ($1- != $null) && ($len($1-) != 2) {
    error.a Invalid language: ' $+ $1- $+ ' - language must be of two letters
    return
  }
  if ($1- != $null)  { _setsetup script _lang $upper($1) }
  if ($show) {
    var %curr = $_getlang,%string = Current language is $upper(%curr),%tmp
    if (%curr == EN) { %tmp = English }
    elseif (%curr == ES) { %tmp = Español }
    elseif (%curr == DE) { %tmp = German }
    elseif (%curr == FR) { %tmp = French }
    elseif (%curr == IT) { %tmp = Italian }
    elseif (%curr == PT) { %tmp = Portuguese }
    elseif (%curr == SV) { %tmp = Swedish }
    if (%tmp != $null) { %string = %string ( $+ %tmp $+ ) }
    info.a %string - use "/lang [EN|ES|DE|FR|IT|PT|SV]" to modify
  }
}
alias _getlang {
  var %lang = $_getsetup(script,_lang)
  if ($len(%lang) == 2) { return %lang }
  return EN
}
;
; VIP
;
alias _loadhashmainsetup {
  var %file = $_usrdir(script.dat)
  _hmake _aircsetup 100
  if ($isfile(%file)) { hload _aircsetup %file }
}


; $_rini(section,item)
alias _rini { return $readini -n " $+ $_scriptini $+ " $1 $2 }

; $_mainini
alias _mainini {
  var %file = usr\main.ini
  if ($isfile(%file) == $false) {
    write -c " $+ %file $+ "
    writeini " $+ %file $+ " main pbaronstart 1
  }
  return %file
}

; $_scriptini
alias _scriptini { return $_usrdir(script.ini) }

; $_rinitxt(item)
alias _rinitxt { return $read -ns $+ $1 $_scriptxtini }

; $_scriptxtini
alias _scriptxtini { return $_usrdir(scriptxt.ini) }

alias _wini {
  if ($1 == $null) {  }
  elseif ($3- == $null) { .remini " $+ $_scriptini $+ " $1 $2 }
  else { .writeini " $+ $_scriptini $+ " $1 $2- }
  .flushini " $+ $_scriptini $+ "
}
alias _winitxt {
  if ($1 == $null) { return }
  var %file = $_scriptxtini
  write -ds $+ $1 " $+ %file $+ "
  if ($2- != $null) { write " $+ %file $+ " $1- }
}

alias _scriptdir { return script\ $+ $1- }
alias _themesdir { return themes\ $+ $1- }
alias _addonsdir { return addons\ $+ $1- }
alias " { return " $+ $remove($1-,") $+ " }
alias _usrdir {
  if (%†usrdir != $null) { return usr\ $+ $ifmatch $+ \ $+ $1- }
  _setusrdir
  return usr\ $+ %†usrdir $+ \ $+ $1-
}
alias _chfile {
  var %file = $remove($1-,")
  if ($isfile(%file) == $false) { write -c " $+ %file $+ " }
  return %file
}
alias _readini { return $readini -n " $+ $_chfile($1) $+ " " $+ $2 $+ " $3 }
alias _writeini {
  if ($1 != $null) && ($2 != $null) && ($3 != $null) {
    if ($4- != $null) { writeini " $+ $1 $+ " " $+ $2 $+ " $3 $4- }
    else { remini " $+ $1 $+ " " $+ $2 $+ " $3 }
  }
}

; $_xcopy(from,to,files,flags)
alias _xcopy {
  var %from = $_fixdir($1),%to = $_fixdir($2),%files = $3,%flags = $4,%win = @__xcopy1,%copy

  if ($isdir(%from) == $false) || ($isdir(%to) == $false) { return }
  if (%files == $null) { %files = * }
  _openwins %win
  _dummy $finddir(%from,*,0,%win)
  _dummy $__xcopy.files(%from,%to,%files,%flags)
  while ($line(%win,0)) {
    .mkdir " $+ $replace($line(%win,1),%from,%to) $+ "
    _dummy $__xcopy.files($line(%win,1),$replace($line(%win,1),%from,%to),%files,%flags)
    dline %win 1
  }
  close -@ %win
}
alias __xcopy.files {
  var %from = $1,%to = $2,%files = $3,%flags = $4,%win = @__xcopy2,%copy,%ff,%tf
  _openwins %win
  _dummy $findfile(%from,*,0,1,%win)
  while ($line(%win,0)) {
    var %copy = 0,%ff = $line(%win,1),%tf = $replace(%ff,%from,%to)
    while (\\ isin %ff) { %ff = $replace(%ff,\\,\) }
    if (l isin %flags) {
      if ($isfile(%tf) == $false) { %copy = 1 }
    }
    else { %copy = 1 }
    if (%copy) { .copy -o " $+ %ff $+ " " $+ %to $+ " }
    dline %win 1
  }
  close -@ %win
}
alias reloadairc {
  var %t = 0
  if ($nopath($isalias(_yesno).fname) == questions.mrc) { %t = $_yesno(1,Reload script [/reloadairc],0,Reload script files?) }
  else { %t = $?!="Reload script files?" }
  if (%t) {
    _scriptfiles.load -aprfm
    if ($result) {
      echo $colour(ctcp) -eist *** ERROR: Files missing/corrupted... Please reinstall. Exiting...
      .timer -o 1 3 _exit
      halt
    }
  }
}
;;
;
; /_scriptfiles.load [-aprfm]
;
alias _scriptfiles.load {
  var %ifile = script\scriptfiles.ini,%error = 0,%win = @__startreload,%i,%file,%flags,%lflags = $1,%force = 0,%meter = 0,%popt,%pfile,%loadr,%total,%porc
  .timer_reloadbasefile 1 0 _reloadbasefile
  if (f isin %lflags) { %force = 1 }
  if (m isin %lflags) && ($isalias(_progress.init)) { %meter = 1 }
  if (a !isin %lflags) && (p !isin %lflags) && (r !isin %lflags) { %lflags = apr }
  if ($isfile(%ifile) == $false) || ($lines(%ifile) <= 1) { %error = 1 }
  else {
    close -@ %win
    window -hlk %win
    if (a isin %lflags) { filter -fw " $+ %ifile $+ " %win -a* }
    if (p isin %lflags) { filter -fw " $+ %ifile $+ " %win -p* }
    if (r isin %lflags) { filter -fw " $+ %ifile $+ " %win -r* }
    if (%meter) {
      _progress.init Reloading script files...
      _progress 0
    }
    var %total = $line(%win,0),%i = %total
    while (%i) {
      var %flags = $gettok($line(%win,%i),1,32),%file = $gettok($line(%win,%i),2-,32)
      if ($isfile(%file) == $false) {
        %error = 1
        close -@ @.progress
        break
      }

      if (%meter) { _progress2 $calc(%total - %i) %total $nopath(%file) }
      if (10 // %i) { _miniprogress $calc(35 - (35 * %i / %total)) }

      if (%file == $remove($script,$mircdir)) {  }
      elseif (p isin %flags) {
        var %popt = $replace($remove(%flags,-,p),s,0,c,1,q,2,n,3,m,4),%pfile = $readini -n " $+ $mircini $+ " pfiles n $+ %popt
        if ($nopath(%file) != $nopath(%pfile)) { .load %flags " $+ %file $+ " }
      }
      elseif (r isin %flags) && ($nofile($script($nopath(%file))) == $mircdir $+ script\) {
        %loadr = 0
        if (%force) { %loadr = 1 }
        elseif ($right(%flags,2) isnum) {
          if ($nopath($script($calc($script(0) + $right(%flags,2) + 1))) != $nopath(%file)) {
            %flags = $replace(%flags,$right(%flags,2),$calc($script(0) + $right(%flags,2) + 1))
            %loadr = 1
          }
        }
        elseif ($right(%flags,1) isnum) && ($nopath($script($right(%flags,1))) != $nopath(%file)) { %loadr = 1 }
        if (%loadr) { .reload %flags " $+ %file $+ " }
      }
      elseif (a isin %flags) && ($nofile($alias($nopath(%file))) == $mircdir $+ script\) {
        %loadr = 0
        if (%force) { %loadr = 1 }
        elseif ($right(%flags,2) isnum) {
          if ($nopath($alias($calc($alias(0) + $right(%flags,2) + 1))) != $nopath(%file)) { %loadr = 1 }
        }
        elseif ($right(%flags,1) isnum) && ($nopath($alias($right(%flags,1))) != $nopath(%file)) { %loadr = 1 }
        if (%loadr) { .load %flags " $+ %file $+ " }
      }
      else { .load %flags " $+ %file $+ " }
      dec %i
    }
    if (%meter) { _progress 100 Done! }
  }
  close -@ %win
  if (%error) { return 1 }
  return 0
}
alias _scriptfiles.save {
  var %ifile = script\scriptfiles.ini,%i = 1,%f,%win = @__scriptfilessave,%first = 7,%last = 6
  close -@ %win
  window -h %win
  while (%i <= $alias(0)) {
    %f = $remove($alias(%i),$mircdir)
    if (script\* iswm %f) {
      if ($nopath(%f) == text.scheme) || ($nopath(%f) == custom_a.mrc) {  }
      else { aline %win -a %f }
    }
    inc %i
  }
  aline %win -ps $readini -n " $+ $mircini $+ " pfiles n0
  aline %win -pc $readini -n " $+ $mircini $+ " pfiles n1
  aline %win -pq $readini -n " $+ $mircini $+ " pfiles n2
  aline %win -pn $readini -n " $+ $mircini $+ " pfiles n3
  aline %win -pm $readini -n " $+ $mircini $+ " pfiles n4
  var %i = 1
  while (%i <= $script(0)) {
    %f = $remove($script(%i),$mircdir)
    if (script\*.mrc iswm %f) {
      if (%i <= %first) { aline %win -rs $+ %i %f }
      elseif (%i >= $calc($script(0) - %last)) { aline %win -rs $+ $calc(%i - $script(0) - 1) %f }
      else { aline %win -rs %f }
    }
    inc %i
  }
  savebuf %win " $+ %ifile $+ "
  close -@ %win
}
alias _reloadbasefile {
  _start.customfiles
  .timer -o 1 0 .reload -rs1 " $+ $script $+ "
}
alias _exit {
  if ($isid) { return }
  .timers off
  if ($version >= 5.71) {
    while ($dialog(1)) { dialog -x $ifmatch }
  }
  else {
    :loop
    if ($dialog(1)) {
      dialog -x $ifmatch
      goto loop
    }
  }
  sockclose *
  close -cfgims@
  exit $1-
}
alias _ini2hashfile {
  var %file = $$1,%table = $$2,%file2 = $$3,%tn,%tm,%in,%im,%topic,%item
  if ($isfile(%file) == $false) {
    error.a No such file: $'(%file)
    return
  }
  _hmake %table 100
  var %tn = 1,%tm = $ini(%file,0)
  while (%tn <= %tm) {
    var %topic = $ini(%file,%tn),%in = 1,%im = $ini(%file,%topic,0)
    while (%in <= %im) {
      %item = $ini(%file,%topic,%in)
      if ($_readini(%file,%topic,%item) != $null) { hadd %table %topic $+ _ $+ %item $ifmatch }
      inc %in
    }
    inc %tn
  }
  hsave -o %table %file2
}
alias _hmake {
  var %name = $1,%num = $round($2,0)
  if ($_not($_isint(%num))) { %num = 15 }
  if (%name == $null) { return }
  if ($hget(%name)) { hfree %name }
  hmake %name %num
}
alias _hadd {
  if ($hget($1)) {
    if ($3- != $null) { hadd $1- }
    else { hdel $1-2 }
  }
}
alias _setsetup {
  _setd setup $1-
  __hashsavebuf _aircsetup script.dat
}
alias _settsetup {
  _setd setup $1-
  _hashsavebuf _aircsetup script.dat
}
alias _get {
  var %table = _airc $+ $1,%item = $2
  if ($3 != $null) { %item = %item $+ _ $+ $3 }
  return $hget(%table,%item)
}
alias _getsetup {
  var %item = $1
  if ($2 != $null) { %item = %item $+ _ $+ $2 }
  return $hget(_aircsetup,%item)
}
alias _sets {
  var %table = _airc $+ $1,%item = $2,%text = $3-
  if ($hget(%table) == $null) { _hmake %table 15 }
  if (%text != $null) { hadd %table %item %text }
  else { hdel %table %item }
}
alias _setd {
  var %table = _airc $+ $1,%item = $2 $+ _ $+ $3,%text = $4-
  if ($hget(%table) == $null) { _hmake %table 15 }
  if (%text != $null) { hadd %table %item %text }
  else { hdel %table %item }
}
alias _delhsection {
  var %table = _airc $+ $1,%item = $2 $+ _*
  if ($hget(%table) == $null) {
    _hmake %table 15
    return
  }
  hdel -w %table %item
}
alias _hashsavebuf {
  var %table = $1,%file = $2
  .timer_savehashbuf $+ %table -mo 1 15 __hashsavebuf %table %file
}
alias __hashsavebuf { hsave -o $$1 " $+ $_usrdir($$2) $+ " }