$args - Immutable list of arguments - 30/11/15 12:38 AM
There's something mIRC's scripting engine is lacking: an intuitive way to preserve and access arguments passed to an event/alias. As such I suggest the following:
$args(n)
References an immutable list of the arguments(the initial values of $1-n) passed to events and custom aliases.
if n is zero, the total number of arguments is returned
if n is greater than zero, the nth argument is returned
First, this would preserve the arguments after retokenization. For events and aliases used as commands this isn't as big of a deal -- the arguments can be stored via something akin to /var %args $1- and accessed via $gettok(%args, n, 32) -- but with custom aliases to be used as identifers to preserve the arguments the script must loop over them and store each one separately:
For a known number of arguments, it may be simpler to store/lookup the arguments without looping but for cases where the alias has an undetermined number of arguments to be preserved a scripted loop is required and is relatively slow; which may lead to cases where mIRC stutters/freezers if such an alias is used extensively. If implemented, then preservation storage would already be done for the user and referencing an nth parameter should be far faster than using current methods:
$args(n)
References an immutable list of the arguments(the initial values of $1-n) passed to events and custom aliases.
if n is zero, the total number of arguments is returned
if n is greater than zero, the nth argument is returned
First, this would preserve the arguments after retokenization. For events and aliases used as commands this isn't as big of a deal -- the arguments can be stored via something akin to /var %args $1- and accessed via $gettok(%args, n, 32) -- but with custom aliases to be used as identifers to preserve the arguments the script must loop over them and store each one separately:
Code:
//echo -a $example(a b c, 1 2 3, x y z, 4 5 6) alias example { var %args0 = $0 var %n = 1 while (%n <= $0) { var %args [ $+ [ %n ] ] = $($ $+ %n, 2) } tokenize 32 ... ;; rest of code }
For a known number of arguments, it may be simpler to store/lookup the arguments without looping but for cases where the alias has an undetermined number of arguments to be preserved a scripted loop is required and is relatively slow; which may lead to cases where mIRC stutters/freezers if such an alias is used extensively. If implemented, then preservation storage would already be done for the user and referencing an nth parameter should be far faster than using current methods:
Code:
; faster echo -a $args(%n) ; slower echo -a %args [ $+ [ %n ] ] echo -a $eval(% $+ args $+ %n, 2)