'From etoys3.0 of 21 February 2008 [latest update: #1963] on 11 April 2008 at 2:29:20 am'! "Change Set: functionNames-sw Date: 10 April 2008 Author: Scott Wallace TRAC6866 - add sign (signum) function. Also, change a few function names to names more appropriate to tile-scripting, given that the function name precedes the argument on tiles: 'squared' changed to 'square' 'cubed' changed to 'cube' 'rounded' changed to 'round' 'negativeOf' changed to 'negate' 'sign' added, representing signum function. 'truncate' added (like round, but rounds toward zero.) 'grouped' changed to 'parentheses', and when parentheses is the current choice, the 'remove' option in the pop-up menu is worded 'remove parentheses' rather than 'remove function'. "! !FunctionNameTile methodsFor: 'choice of function' stamp: 'sw 4/11/2008 02:25'! showOptions "Put up a pop-up menu of options for the operator tile within me." | aMenu aTable | aMenu := MenuMorph new defaultTarget: self. aTable := ScriptingSystem tableOfNumericFunctions. aTable do: [:triplet | aMenu add: triplet first target: self selector: #setOperator: argument: triplet second. triplet second = operatorOrExpression ifTrue: [aMenu lastItem color: Color red]. aMenu balloonTextForLastItem: triplet third]. aMenu addTranslatedList: #(- ('parentheses' grouped 'enclose within parentheses')) translatedNoop. operatorOrExpression = #grouped ifTrue: [aMenu lastItem color: Color red]. (owner owner isKindOf: TilePadMorph) ifTrue: [aMenu addLine. operatorOrExpression = #grouped ifFalse: [aMenu addTranslatedList: #(('remove function' removeFunction 'strip away the function call, leaving just its former argument in its place')) translatedNoop.] ifTrue: [aMenu addTranslatedList: #(('remove parentheses' removeFunction 'strip away the parenthesises')) translatedNoop]]. aMenu position: self position. aMenu invokeModal ! ! !StandardScriptingSystem methodsFor: 'utilities' stamp: 'sw 4/10/2008 17:41'! tableOfNumericFunctions "Answer an array of triplets." " English on tile selector English balloon help" ^ #( (abs abs 'absolute value') (arcTan arcTan 'angle, in radians, whose tangent is the argument') (cos cos 'trigonometric cosine, argument in radians') (cube cubed 'the argument times itself, times itself again') (cubeRoot cubeRoot 'cube root of the argument') (degreeArcTan degreeArcTan 'angle, in degrees, whose tangent is the argument') (degreeCos degreeCos 'trigonometric cosine, argument in degrees') (degreeSin degreeSin 'trignometric sine, argument in degrees') (degreeTan degreeTan 'trigonometric tangent, argument in degrees') (degreesToRadians degreesToRadians 'the number of degrees equivalent to the argument which is assumed to be expressed in radians') (exp exp 'exponential (e to the power of the argument)') (factorial safeFactorial 'the product of all the whole numbers between 1 and the argument') (ln safeLn 'natural logarithm') (log safeLog 'logarithm, base 10') (negate negated 'the negative of the argument') (radiansToDegrees radiansToDegrees 'the number of radians equivalent to the argument, which is expressed in degrees.') (random random 'a randomly chosen integer between 1 and the argument') (round rounded 'the integer closest to the argument.') (sign sign '1 if argument is positive, -1 if argument is negative, 0 if argument is zero.') (sin sin 'trigonometric sine, argument in radians') (square squared 'the argument multiplied by itself') (squareRoot safeSquareRoot 'square root of the argument') (tan tan 'trigonometric tangent, argument in radians') (truncate truncated 'the integer nearest to the argument toward zero') ) translatedNoop " (raisedto raisedTo: 'raised to the power') "! !