I think the main purpose for switch structures (in other languages) is to allow "fall-through" situations. Example:
This has all been hashed over at least once before. Sure its usefull, but its not something that cant be emulated by the simple IF statement.
I think khaled just doesnt see any reason to have to make it more complex on the scripting phraser than it already is
Dont get me wrong, i would be one of the first to use it, if it had it, but im not sobbing into my cornflakes that its not here either.
as for drop through
while ($1 == $1) {
var %dropthrough = $false
if (($1 == .fred) || %dropthrough) { %dropthrough = $true | ..... .fred code ..... | break }
if (($1 == .mike) || %dropthrough) { %dropthrough = $true | ..... .mike code ..... }
if (($1 == .bill) || %dropthrough) { %dropthrough = $true | ..... .bill code ..... | break }
.... else code ....
break
}
yours even, using smaller vars so as to not over welm whats important...
while (%x == %x) {
var %dt = $false
if (%dt || (%x == 1)) { %dt = $true }
if (%dt || (%x == 2)) { %dt = $true
echo -a x = 1 or 2
break }
if (%dt || (%x == 3)) { %dt = $true }
if (%dt || (%x == 5)) { %dt = $true }
if (%dt || (%x == 5)) { %dt = $true
echo -a x = 3 or 5 or 9
break }
;default:
echo -a x is invalid
break
}
* moved the %dt to the front to speed up comparasions on already matched lines. (well maybe, might actually slow it down who knows)
I disagree with using goto statements, it limits the scope of the case select statement and u cant have two simulated case/selects with the same labels in them else your asking for a duplicate goto/label found error.