Maybe it would be usefull if mIRC's scripting language contained a switch statement as almost every language has. When you have to check a var against a lot of values, you have to use A LOT of if-else statements, which is very annoying. Switch statements would also make scripts more readable.
If you know that the label will exist, you can also use a GOTO jump as a fast and clean alternative to lots of IF statements.
Thats ugly and also doesn't support the 'default' case.
Either you forget too much or you're lying :tongue: We've discussed this in an older thread and it was shown that there IS a way to have a 'default' case:
var %a = $1
goto %a
:1 | return One
:2 | return Two
:3 | return Three
:%a | return Default
If the value of the variable is not among the text labels, mirc jumps to the special label named after the variable name itself. It may look a little weird and it's not documented anywhere but it works perfect.
yes but thats not really right. Meaning you can't
switch ($left($1,1)) {
case a:
echo -a it's an a
default:
echo -a it's not an a
}
You would have to assign the return value of $left to a variable, which makes it messy. Also it gets even more messy if you want to use something with spaces because instead of:
case "this is a test"
You need to
:this $+ is $+ a $+ test
But afaik, that doesn't even work, because mIRC doesn't evaluate an identifier in a label, so that would simply translate to ":this" which most likely, is not what the scripter would have intended.
I realise the limitations of the goto solution and I too would like a switch in mirc. I was just replying to your claim that you cannot have a 'default' case, grabbing the opportunity to inform the original poster of this feature (if he didn't know already).