Writing Extensions

Mike Kerner MikeKerner at roadrunner.com
Wed May 24 09:11:30 EDT 2017


I personally hate switch.  That said, getting rid of the CR's would help
make the new "choose" easier to read.  If you want a CR, use \

choose tValue
 when 1 or 2 or 3
  -- do something
end choose

choose tValue
 when 1\
 or 2\
 or 3
  -- do something
end choose

On Wed, May 24, 2017 at 9:03 AM, Kay C Lan via use-livecode <
use-livecode at lists.runrev.com> wrote:

> On Wed, May 24, 2017 at 8:25 PM, Mark Waddingham via use-livecode
> <use-livecode at lists.runrev.com> wrote:
> >
> Thanks Mark for the explanation.
>
> >   choose tValue
> >     when 1
> >     when 2
> >     when 3
> >       -- executes if tValue is 1, 2 or 3
> >       -- never falls through
> >
> >     when 4
> >       -- never falls through
> >
> >     default
> >   end choose
> >
> > This caters for both cases (1) and (2) and is unambiguous.
> >
> Whilst I certainly like the above and think it an improvement, if I
> were to 'step back' and redesign Switch I think I'd make it clearer
> that 'fall through' is just an OR - it took me ages to realise and
> I've have very very long: case ((....) OR (....) OR (....) ....) which
> were extremely long and very hard to read until I rewrote them as
>
> case
> case
> case
> case
> ---do something
> break
>
> What I can't currently solve is the many case ((.....) AND (,,,,) AND
> (....) AND (...)... )
>
> So, again if I were reinventing Switch:
>
> choose tVale
>   when 1
>   or 2
>   or 3
>     --do something
>     -- no further fall through
>   when > 6
>   and < 60
>   and even
>     --do something else
>     --no further fall through
>   when 4
>     --do another thing
>   default
>     --some other thing
> end choose
>
> Just makes it clear that fall through is being used to combine the
> statements, but in my design it isn't just restricted to OR.
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."



More information about the use-livecode mailing list