Alternative To A Specific Switch Statement

Peter M. Brigham pmbrig at gmail.com
Fri Mar 15 08:11:02 EDT 2013


On Mar 14, 2013, at 2:08 PM, kee nethery wrote:

> I would do the calc once.
> I would make the last one default just in case the calc provides you with something funky.
> Kee
> 
> __put sin(pAngleInRadians) into sinCalc
> __switch
> ____case sinCalc > 0
> ______put 1 into tX
> ______break
> ____case sinCalc = 0
> ______put 0 into tX
> ______break
> ____default
> ______put -1 into tX
> ______break
> __end switch

And combining the suggestions, you could do:

put sin(pAngleInRadians) into sinCalc
switch sinCalc
   case 0
      put 0 into tX
      break
   default
      put sinCalc/abs(sinCalc) into tX
end switch

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig






More information about the use-livecode mailing list