This is probably a hold-over from my formative years programming a 64KB Atari, but I try to reduce the number of variables used, if possible. This is situationally dependent, of course, and may not work in all instances. That's why I really like Alex's offering. It is elegant, minimizes conditional statements, and uses only one variable.
On Thu, Mar 14, 2013 at 1:06 PM, Alex Tweedly <a...@tweedly.net> wrote: > > 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, dunb...@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 <endern...@gmail.com> >> To: List LiveCode <use-livecode@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@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@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode