Alternative To A Specific Switch Statement

Alex Tweedly alex at tweedly.net
Thu Mar 14 14:06:53 EDT 2013


I have to agree it's pretty readable right now.

If you *really* want a shorter, less readable, way, try ....

put sin(pAngleInRadians) into tX
if tX <> 0 then divide tX by abs(tX)

-- Alex.

On 14/03/2013 17:56, dunbarx at aol.com wrote:
> Hi.
>
>
> This is a pretty tight switch construct, of a typical form. And very readable. What makes you feel it ought to be tightened?
>
>
> Craig Newman
>
>
>
>
>
> -----Original Message-----
> From: Ender Nafi Elekçioğ
>   lu <endernafi at gmail.com>
> To: List LiveCode <use-livecode at lists.runrev.com>
> Sent: Thu, Mar 14, 2013 1:37 pm
> Subject: Alternative To A Specific Switch Statement
>
>
> Hello Dear LiveCode Gurus,
>
>
>
> Here is a little code snippet:
>
> __switch
> ____case sin(pAngleInRadians) > 0
> ______put 1 into tX
> ______break
> ____case sin(pAngleInRadians) = 0
> ______put 0 into tX
> ______break
> ____case sin(pAngleInRadians) < 0
> ______put -1 into tX
> ______break
> __end switch
>
> It's for a complex rotation command.
> Is there a more elegant way to achieve the same result with built-in functions?
> I mean, something like a combination of abs(), max() and/or round()?
> Just an intellectual curiosity :)
>
> Thanks for any insights...
>
>
> Best,
>
> ~ Ender Nafi
>
>
>
> ~ ·   together, we're smarter  · ~
>
> ~ ·  Keehuna Studio
> ~ ·  Sorcerers of Design
>
> _______________________________________________
> 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
>
>   
> _______________________________________________
> 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





More information about the use-livecode mailing list