well someone thought that it was impossible to have a switch-like statement in mIRC, so i figured I'd give it a try
alias switch {
var %condition = $1,%1 = $$2-,%def = $true
if (!$regex(switch,%1,/(?:case\W([^ ]+)|(default))\x3A\W(.+?)break/Sig)) { echo -a Syntax error! | halt }
var %x = $regml(switch,0),%c = 1
while (%c <= %x) {
if ((%condition == $regml(switch,%c)) || (%def && $regml(switch,%c) == default)) {
var %def = $false,%reg = $regml(switch,$calc(%c +1)),%xx = $numtok(%reg,124),%xxx = 1
while (%xxx <= %xx) {
$($gettok(%reg,%xxx,124),2)
inc %xxx
}
}
inc %c 2
}
}
looks like someone has already made it.
http://www.mircscripts.org/showdoc.php?type=code&id=4491
its a great looking script btw, nice compact use of COM too.
i think it has many practical uses. many site offer a JSON web service
even google offers a multitude:
youtube
dictionary
web search
translate
to name a few
And as for parsing, you could use a COM call to MSScriptControl.ScriptControl
but anyway, it seems im alone in thinking there is a practical use for this in mirc. ah well
it's a good idea, but unfortunately the syntax required is awkward and imposes too many annoyances on the user such as:
while it is possible to implement this with less awkward syntax and improve upon it by trimming this list of annoyances, we cannot escape the fact that, in mIRC, /goto provides the most simple and efficient switch statement analogy ;P however, like that 'arrays in mIRC' demonstration from a while back, this serves as a fun and thought provoking demonstration