compound if alternatives
Scott Rossi
scott at tactilemedia.com
Sat Jan 24 00:20:29 EST 2004
Recently, I wrote:
>> if c < t1 then
>> do1
>> else if c >= t1 and c < t2 then
>> do2
>> else if c >= t2 and c < t3 then
>> do3
>> ...
>> else if c >= t7 then
>> do8
>> end if
>>
>> Anyone any ideas? I seem to have a "writer's block" :(
>
> You could try switch:
>
> switch
> case c < t1
> do1
> case c < t2
> do2
> case c < t3
> do3
> ...
> case c < t8
> do8
> end switch
>
> Note there are no breaks between case statements so the script should run
> through all options until it finds a valid equation.
Doh -- ignore the "breaks" comment above (not sure why I left them out --
fatigue?). Include the breaks to prevent the script from returning multiple
true statements (unless you want multiple true statements).
switch
case c < t1
do1
break
case c < t2
do2
break
case c < t3
do3
break
...
case c < t8
do8
end switch
Regards,
Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com
More information about the use-livecode
mailing list