mIRC Homepage
Posted By: dominic_eddy 'unloadall' scripts - 09/04/11 09:52 AM
im suggesting something for the remote.
well, i have alot of scripts for my bot smile and when i join irc with both him and me, i always have to unload the scripts for me (i only want the scripts loaded on my bot) so i was wondering as well as an 'unload' option also an 'unloadall' to save me and probably others from having to take ages unloading all the scripts we have. and maybe a loadall command too would be useful smile
Posted By: Horstl Re: 'unloadall' scripts - 09/04/11 10:37 AM
It seems to me that /remote on|off would suffice in your case?

But why not set up two "different" mIRC so you don't have to toggle at all (Either: two distinct installation folders containing a distinct mirc.ini file each, or: one mirc installation but two distinct shortcuts that use the "-i" command line option to point to different ini files)?
Posted By: argv0 Re: 'unloadall' scripts - 09/04/11 06:04 PM
/unloadall is a very easy script that you can place in your aliases:

Code:
/unloadall var %i = 1 | while ($script(%i)) { unload -rs $v1 | inc %i }


How would a /loadall work? Once unloaded, mIRC doesn't know what "all" is. The only thing I could think of would be to pass "all" scripts in as arguments to the command, but that wouldn't make loading scripts all that much easier.

However, you could similarly write an alias /loadall that works for you:

Code:
/loadall {
  load -rs scriptX.mrc
  load -rs scriptY.mrc
  load -rs foobar.mrc
  ...
}


Note that this could support loading aliases and popups too, something a simple "/loadall <script> <script> <script>" syntax wouldn't be able to capture.
Posted By: hixxy Re: 'unloadall' scripts - 10/04/11 01:14 AM
There is a logical bug in your script.

Your script:

Code:
/unloadall var %i = 1 | while ($script(%i)) { unload -rs $v1 | inc %i }


If you have 5 scripts loaded, it will do this:

%i = 1
unload script 1
increase %i to 2
script 2 becomes script 1, script 3 becomes script 2, and so forth...
unload script 2, leaving script 1 loaded
..etc

You need to go backwards instead:

Code:
alias unloadall var %i = $script(0) | while (%i) { unload -rs $script(%i) | dec %i }
Posted By: argv0 Re: 'unloadall' scripts - 10/04/11 04:28 AM
Good catch, or you could not inc/dec at all and do:

Code:
/unloadall while ($script(1)) unload -rs $v1


Note that there's a logical bug in your script. Since it's a remote alias (alias prefix), it will be unloaded smile
Posted By: FroggieDaFrog Re: 'unloadall' scripts - 10/04/11 07:29 AM
/UnloadAll - Unloads all remote files, and saves the names to a file

/ReloadAll - Loads all scripts that were unloaded with /Unloadall and removes the file.

Place the following in the aliases section:
Code:
UnloadAll {
  if (!$script(0)) return
  if ($isfile(MyUnloadedScripts.txt)) .remove MyUnloadedScripts.txt
  while ($script(1)) {
    write MyUnloadScripts.txt $v1
    .unload -rs
  }
}
ReloadAll {
  if ($isfile(MyUnloadedScripts.txt)) {
    var %i = 1
    while ($read(MyUnloadedScripts.txt,n,%i)) {
      .load -rs $qt($v1)
      inc %i
    }
    .remove MyUnloadedScripts.txt
  }
}


There was a logical bug in my script that would attempt to remove MyUnloadedScripts.ini instead of .txt
Posted By: Riamus2 Re: 'unloadall' scripts - 10/04/11 12:13 PM
I think you want $v1 (or $qt($v1) ) in your unload command. smile
Posted By: FroggieDaFrog Re: 'unloadall' scripts - 10/04/11 01:43 PM
I do believe you are correct!
Posted By: hixxy Re: 'unloadall' scripts - 10/04/11 02:01 PM
That script goes into an infinite loop. mIRC never has 0 scripts loaded. If you unload your final named script, it will automatically add a script with a generic name like "Script1.mrc." This is the reason I use a "while (%i)" loop instead of "while ($script(%i))"

Nice catch on the fact I've added a remote alias.. we need to combine your and my efforts:

Code:
unloadall var %i = $script(0) | while (%i) { unload -rs $script(%i) | dec %i }


To place in aliases.

Edit:

Froggie, your script has the same problem. while ($script(1)) { } will go into an infinite loop because mIRC never has 0 scripts loaded. Try it out yourself.
Posted By: FroggieDaFrog Re: 'unloadall' scripts - 10/04/11 02:20 PM
Fixed (I think):
Code:
UnloadAll {
  if (!$script(0)) return
  if ($isfile(MyUnloadedScripts.txt)) .remove MyUnloadedScripts.txt
  var %i = $script(0)
  while (%i) {
    write MyUnloadScripts.txt $script(%i)
    .unload -rs $qt($script(%i))
    dec %i
  }
}
ReloadAll {
  if ($isfile(MyUnloadedScripts.txt)) {
    var %i = 1
    while ($read(MyUnloadedScripts.txt,n,%i)) {
      .load -rs $qt($v1)
      inc %i
    }
    .remove MyUnloadedScripts.txt
  }
}
Posted By: hixxy Re: 'unloadall' scripts - 10/04/11 04:47 PM
Looks good to me, but you should use the 't' switch with $read() in case one of the scripts was just named as a number.

As you can see a script can be called just a number:

Code:
//write 1 | load -rs 1 | unload -rs 1 | remove 1
© mIRC Discussion Forums