Most scripters are familiar with the concept of evaluation bracket and how [[ and ]] can be used inside a script to get [ and ] as the characters instead.
This feature's description has been removed from the help file it seems, I'm not sure it was there before, but how else would we know?

But what if I tell you this feature was probably removed from the help file for good reason?!

The help file's description of bracket evaluation is very very very light:

Quote
The [ ] evaluation brackets

If you want greater control over the order of evaluation of identifiers, you can use the [ ] brackets. Identifiers within these brackets will be evaluated first, from left to right. You can nest brackets.

/say % [ $+ [ $1 ] ]

You can also force a previously evaluated identifier to be re-evaluated by using extra [ ] brackets.

/set %x %y

/set %y Hiya!

/echo [ [ %x ] ]
And that's it.
In reality bracket evaluation are much much more complex than that. This post isn't about updating the help file there but I certainly wouldn't mind.
The interesting part here is how [ ] are handled and at which stage in mIRC's processing of your code.
They are handled before anything else, unlike $eval, it is as though you were literally rewriting the line of code in memory.

This is why //var %a 255,255,255 | echo -ag $rgb( [ %a ] ) works and why $rgb($eval(%a)) would fail (it would be sending a single parameter containing commas to $rgb)

I was helping TECO who needed dynamically built regex pattern to highlight him correctly, and that included matching eventual channel prefix ($prefix) on the left of his nickname, I had chosen to use [[ and ]] with $+

Quote
[14:49:40] <Ouims> //var -s %p /(?:^|\x20| $+ [[ $+ $prefix $+ ]] $+ ++ $+ ) $+ $me $+ (?:[:\x2c.](?: |$)|$)/iS | say $regex(#TECOTECO#123456 $+ $chr(44) o Ouims.,%p) $regerrstr
[14:49:43] <Ouims> this works
[14:49:49] <Ouims> //say $regex(#TECOTECO#123456 $+ $chr(44) o Ouims.,/(?:^|\x20| $+ [[ $+ $prefix $+ ]] $+ ++ $+ ) $+ $me $+ (?:[:\x2c.](?: |$)|$)/iS) $regerrstr
[14:49:59] <Ouims> this is the same but -14 and nothing to repeat error from pcre

If you can see the mistake I made when not using %p at this point, well, kudos (or how much did you pay jaytea?!)

So, another main idea of how the scripting language works is that a line of code and a parameter to an identifier are handled by the same routine, this is, coupled with [[ ]] usage above, the point of this post.
In normal time, mIRC remember where he already replaced some [ ] pair or [[ ]] pair, this can be illustrated by:

//echo -ag A [ $+ B $+ ] C -- $mid(A [[ $+ B $+ ]] C,1)displaying ABC -- A [B] C

What's not normal time then? It's when you add $+ on the outside of the [[ ]] pair which is what I'm doing above inside $regex.
Let's put a single $+ on the right of the pair:

//echo -ag A [ $+ B $+ ] $+ C -- $mid(A [[ $+ B $+ ]] $+ C,1)displays ABC -- ABC, showing that when $mid check its parameter and sees the first parameter 'A [ $+ B $+ ] $+ C' mIRC no longer remember that it must not touch that new [ ] pair and handle it as evaluation bracket.

Let's put a single $+ on the left:

//echo -ag A $+ [ $+ B $+ ] C -- $mid(A $+ [[ $+ B $+ ]] C,1)displays A-- A[B] C, showing that mIRC did remember this time for the [[ ]] inside the $mid. "A--" can be more or less explained, "[ A $+ ] B" is a known odd format which is not useful, this case seems to be a mix of it and because of the extra $+ on the left of [[, B and C are completely removed but it's not really important.

Let's put both like in my $regex above:

//echo -ag A $+ [ $+ B $+ ] $+ C -- $mid(A $+ [[ $+ B $+ ]] $+ C,1) displays AC -- AC, showing that well A $+ [ $+ B $+ ] $+ C = AC, but definitely showing that it's the $+ on the right that makes the [[ $+ B $+ ]] part gone in my code, resulting in the quantifier '++' being attached to nothing.


Conclusion? Don't use [[ ]] to get [ ] when it comes in pair, as inside an identifier with the wrong $+ placement, you'll get unexpected result although the code is technically correct, use $chr(91) and $chr(93), and this is I believe why it's deprecated and why it was removed from the help file.


Thanks for watching!


#mircscripting @ irc.swiftirc.net == the best mIRC help channel