-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Alas, the rather stupid syntax introduced by C (or some older language) and quickly adopted by the masses! Stupid nevertheless.
In C, Transcript, etc. - once you match a single 'case', any future 'case' items are ignored. 'break' gets you out. This is because C, etc. limit you to *one* matching item per 'case'; in essence:
switch whatever case 1: do this; break; case 2: do this; break; ... end switch
what if you want the same code to execute for both 3 and 4? In C/Transcript, you can't do this:
switch whatever case 3, 4: do this; break; ... end switch
so you do this instead:
switch whatever case 3: case 4: do this; break; ... end switch
and the 'case 4' is ignored if the '3' matches, allowing for multiple matching cases like this. Pascal, Ada, etc. have the superior syntax; in Ada for example:
case whatever is
when 1 ==> do this;
when 2 ==> do this;
when 3 | 4 ==> do this;
when others ==> do this;
end case;No messy 'break' statements to deal with, and it is still rather readable. You can do ranges, too, like
when 4..7 ==> do this;
Pascal's syntax looks slightly different, but is similar:
case whatever of
1: do this;
2: do this;
3, 4: do this;
end;
On Feb 2, 2005, at 6:17 PM, Sivakatirswami wrote:
Dan, Indeed, one would expect the drop-through if there is no "break"
but, how would
case "Quit"
evaluate to "true" when the parameter passed from the menuPick was "Print" ??
That's what is mysterious.
Sivakatirswami
On Feb 1, 2005, at 6:38 PM, Dan Shafer wrote:
Actually, the drop-through is exactly what I'd expect. ;-) Otherwise, how would you execute more than one case in a switch statement?
On Feb 1, 2005, at 8:09 PM, Sivakatirswami wrote:
one would not expect the switch to dropdown to "quit" since quit was not chosen, but that appears to be what happened.
_______________________________________________ use-revolution mailing list [email protected] http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________ use-revolution mailing list [email protected] http://lists.runrev.com/mailman/listinfo/use-revolution
- ----------------------------------------------------------- Frank D. Engel, Jr. <[EMAIL PROTECTED]>
$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life.
$
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
iD8DBQFCAW8D7aqtWrR9cZoRAsEYAJ9+v6KqR2PTrDZjMxk8Qkp7E7UhwgCfS9G6 G+mIHPJJVnEV79RTfevyFfY= =BKxd -----END PGP SIGNATURE-----
___________________________________________________________ $0 Web Hosting with up to 120MB web space, 1000 MB Transfer 10 Personalized POP and Web E-mail Accounts, and much more. Signup at www.doteasy.com
_______________________________________________ use-revolution mailing list [email protected] http://lists.runrev.com/mailman/listinfo/use-revolution
