mIRC Home    About    Download    Register    News    Help

Print Thread
#227630 16/11/10 02:45 PM
Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
I've always wondered about var and $+ how the = makes strange behavior. It's been in mirc for a LONG time. Example.

//var %a $+ b = c | echo -a %ab
output: = c

BUT

//var %a = $+ b c | echo -a %ab
output: c



Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
this is a side effect of a rather necessary series of steps that mIRC goes through for /var to work. /var, like /if and /while, is special in that it isn't interpreted via the usual 'evaluate the line -> split it up into a collection of tokens -> call the appropriate command' procedure. that's why //va $+ r %a isn't recognized as a usage of /var.

if /var is detected, the line is split up into a collection of declarations based on the position, if any, of the commas. each declaration is translated into /set -l %var value; this is where the problem you're observing comes from. the rule appears to be "if the space delimited token after the variable name is '=' then don't include it in the translation". that's why %a = $+ b c becomes set -l %a $+ b c and works as desired.

all this occurs BEFORE the evaluation of code in the line. that's why your first example doesn't work as expected: %a $+ b = c becomes set -l %a $+ b = c. the first token after the variable name is '$+', not '=', so the '=' is preserved. for your first example to work as the second example does, the translation procedure would presumably be modified so that it carries on searching for an = to discard past the first token after the variable name if that token is '$+', and past the next 2 if another '$+' is met, and so on.


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Link Copied to Clipboard