The Conference. RE switch
stephen barncard
stephenREVOLUTION2 at barncard.com
Sat Sep 5 12:51:41 EDT 2009
I really like to use switch for any logic more than a single if-then-else.
Switch statements, due to their fall-through and default behaviors, can
handle more logic *conditions* than if-then
switch tInput
case 0
case 1
put tInput after tOut
case 2
put tInput after tOut
case 3
put tInput after tOut
break
case 4
put tInput after tOut
case 5
put tInput after tOut
break
default
put tInput after tOut
end switch
tInput - tOut
0 ==> 123
1 ==> 123
2 ==> 23
3 ==> 3
4 ==> 45
5 ==> 5
6 ==> 6
7 ==> 7
...
when one gets used to the structure of a switch statement, it really looks
like it functions, and it's quite simple. Same thing with arrays.
All programming is simple, once one can break it down as smaller ideas put
together as a machine.
-------------------------
Stephen Barncard
San Francisco
http://houseofcubes.com/disco.irev
2009/9/5 Colin Holgate <coiin at verizon.net>
>
> On Sep 5, 2009, at 12:03 PM, Richmond Mathewson wrote:
>
> Using SWITCH statements,
>>
>
>
> Although switch statements can be useful, you don't have to use them. So
> your old code could stay as it is, and you would just use switch in the
> future if it's appropriate. You can often get away without an if or a
> switch. Like with your example:
>
> do item Goofy of "something-or-other,something-more-foolish"
>
>
>
More information about the use-livecode
mailing list