Capture the Trig Function from an Option Menu Button
Jim Hurley
jhurley0305 at sbcglobal.net
Mon Dec 10 11:00:51 EST 2012
Sorry, Roger, I guess I forgot about that part.
Try the script below:
>> On Dec 9, 2012, at 8:47 PM, Jim Hurley <jhurley0305 at sbcglobal.net
>> > wrote:
>> In Roger Guay's problem it is a two step process, (1) get the value for the trig function and then (2) a statement, and them combine them into a printed statement.
>> This process might be easier to read, and simpler to execute as a Switch/Case solution.
>>
>
> Not quite! My problem was to get the user selected trig fctn (sin, cos or tan) , derive an angle from an incrementing repeat loop, and then calculate the that trig Fctn for the incremented angle, and finally to plot that point on X-Y plane. I'm just saying….
>
> Roger
>
on mouseUp
put the label of btn "myOptionMenu" into tTrigFunction
put round(the width of this card/2) into x0
put round(the height of this card/2) into y0
put 60 into Amp
set the points of grc "myCurve" to empty
wait 0 millisec -- Force a screen refresh on the Mac
repeat with i = 1 to 360--maybe with a step of 2 or 4
put i*pi/180 into tAngle
switch tTrigFunction
case "sine"
put sin(tAngle ) into y
break
case "cosine"
put cos(tAngle) into y
break
case "tangent"
if i = 90 or i = 90+180 then next repeat
put tan(tAngle ) into y
break
end switch
put round(Amp*y) into y
put i into x
put x+ x0, y+y0 into tPoint
put tPoint & cr after tPoints
--Uncomment the following to see the curve evolve
-- set the points of grc "myCurve" to tPoints
-- wait 0 millisec
end repeat
set the points of grc "myCurve" to tPoints
end mouseUp
More information about the use-livecode
mailing list