Capture the Trig Function from an Option Menu Button
Jim Hurley
jhurley0305 at sbcglobal.net
Sat Dec 8 14:25:52 EST 2012
I put my script into a separate button. I think yours was in the Option button.
Put this script into your Option button:
on menuPick pItemName
put field 1 into tAngle --Or wherever your angle is located
put tAngle*pi/180 into tAngle
put pItemName into tTrigFunct
switch tTrigFunct
case "sine"
put sin(tAngle) into tValue
put "The sine of " & tAngle*180/pi & " degrees is " & tValue into tResult
break
case "cosine"
put cos(tAngle) into tValue
put "The cosine of " & tAngle*180/pi & " is " & tValue into tResult
break
case "tangent"
put tan(tAngle) into tValue
put "The Tangent of " & tAngle*180/pi & " is " & tValue into tResult
end switch
put tResult into field 2
end menuPick
You should get a field 2 that locks like this, if the angle is 45 degrees::
The sine of 45 degrees is 0.707107
Is that the results you wanted?
Jim
> Hi Jim,
>
> I was trying to directly use the label of an option menu button (with sin, cos and tan as menu items) and combining that with the angle derived in another script. Something like:
>
> put (the label of btn myOptionMenu)&"("&tangle&")"
>
> This result in something like:
>
> Sin(tangle)
>
>
> And I had trouble figuring out how to evaluate this.
>
> BTW, Your script doesn't work for me. Does it work for you?
>
>
> Thanks,
> Roger
More information about the use-livecode
mailing list