One of the frustrating hurtles with writing a good script, is making it easy to configure and expand upon by third-party users.

I wish to propose a solution that would allow greater ability for modular coding while not being too outlandish in expectation.

SUB [-l] SubRoutineName

Similar to the ALIAS prefix in the Remotes section, but different in the following aspects:

* All local variables are preserved from the calling Alias or Event.

* All local variables set will become available to the calling Alias or Event when the SubRoutine returns.

* All event identifiers are preserved from the calling Event (I know this is already mostly done for Aliase called inside Events).

GoSub SubRoutineName

* Similar to calling an alias.


In actuality, the SUB prefix is not entirely necessary, as the GoSub command can be used in tandem with the existing ALIAS prefix and namespace. The only difference being that Aliases called with GoSub will inherit the caller's local variable scope.

This would be exceedingly useful for setting CONSTANTS and USER MODIFIABLE SCRIPT SECTIONS, placed at the beginning of the script file, or in a file separate from the main body of code.

Examples:
Code:
SUB -l SET_CONSTANTS {
  ; Modify these values as you see fit.
  var %bot.name = MyGoatBot
  var %bot.owner = MeMyselfI
}

; ...

; ...

On *:PART:#: {
  GoSub SET_CONSTANTS
  if ($me == %bot.name) && ($nick == %bot.owner) {
    part $chan wait for me!
  }
}


I know this is a pretty weak example, as you could easily set these two variables globally, but when working in a multi-server environment and especially multi-socket environment, this type of variable inheritance would be ideal.

The main attraction is that you don't have to pass all sorts of values to the Alias, and then retrieve them through use of $1 $2 3- etc. They are already available. (ByRef!)


Well. At least I won lunch.
Good philosophy, see good in bad, I like!