mIRC Scripting

mIRC: Goto Loops

Goto commands let you jump to another statement in a script. This can be very handy when you need to quickly go to another statement or even repeat a previous statement.

:Section
/goto Section

If for any reason you mistakenly caused your script to execute endlessly, you manually break the loop using the Ctrl+Break (sometimes ‘Pause’) shortcut key.

Here is a small 1-10 counter using goto:

Alias Count {
  :loop
  var %c $calc(%c + 1)
  echo -a %c
  if (%c <= 9) goto loop
}

Error Checking

The “:error” is a designated goto section for error checking. If there is an error in the script, mIRC will execute this section. This gives you the ability to continue with the script regardless of the error.

Alias Example {
  /*
    Second parameters of the $rand identifier is missing.
    Deliberate Error
  */

  echo -a $rand(1,)
  return
  :error
  echo -a Error: $error
}

Error Resetting

Using the /reseterror you can continue on with the rest of the script. Not resetting the error will halt script execution (in such case, mIRC will keep looking for ”:error” in all calling aliases).

Alias Foo {
  echo -a $FooBar
}
Alias Bar {
  return $mid($1)
}
Alias FooBar {
  return $Bar(Example)
  :error
  echo -a Error Using Value 1000 instead! ( $+ $error $+ )
  reseterror
  return 1000
}