Using the Symbol Editor > Using More Features of the Symbol Editor > Expressions

Expressions are used to customize the format and value of a parameter. For example, you can use an expression to do the following to an object:

An expression can be set on any attribute contained in a symbol. To use an expression on an object, do the following:

  1. Open the symbol you made in Creating a Rotation Interactor for Multiple Objects.
  2. Select the Text object.
  3. Click the Text tab in the Styling Customizer.
  4. Right-click the Label field. A shortcut menu appears.
  5. Click Enter an Expression.
  6. Delete the contents of the Label field. It is changed into a drop down list.
  7. Click the down arrow on the right of the Label field. The list of expressions appears.
  8. Select the @rotationValue expression.
  9. Fill in the expression as follows, rotationValue(0,360,@rotate,0,360).
  10. Test this symbol by clicking the Preview button.

As you rotate the mouse over the symbol, the Text label is updated to show the angle of rotation.

Expressions can combine other expressions, model attributes and string literals. For example, the following expression prints the integer value of a parameter in a string.

concat("the rotation value is ", rotationValue(0,360,@rotate,0,360), ".")

Note
When creating expressions, always select values from the list, do not type the parameter name or expression by hand.

Possible expressions are listed in Table 2.2.

Table 2.2 Symbol Editor Expressions
Name 
Description 
Example 
parameter 
Any parameter in the symbol 
@rotate 
rotationValue 
Calculates the rotation angle 
rotationValue(@rotate) 
int 
Casts the parameter to an Integer 
int(@rotate&100) 
decimalFormat 
decimalFormat("#.#", pi) -> 3.1 
childrenCount 
Returns the number of child objects below this object 
childrenCount()=0 
simpleDateFormat 
simpleDateFormat("MM/dd/yyyy",@date) 
This will give: 10/01/2001 
long 
Casts to a long value 
long(@val1+@val2) 
double 
Casts to a double value 
double(@value*3) 
messageFormat 
messageFormat('{0}: {1,number,#.##}','result',44.2874)  
This will give: 44.28" 
blinkingColor 
Specifies 2 different colors to alternate for a graphic object 
blinkingColor(green,yellow) 
concat 
Concatenation for String parameters 
concat("result is:",@result) 
float 
Casts parameter to a float value 
float(cos(@value)) 
abs 
Absolute value of the parameter 
acos 
Returns the arc cosine of an angle, in the range of 0.0 through pi 
asin 
Returns the arc sine of an angle, in the range of -pi/2 through pi/2 
atan 
Returns the arc tangent of an angle, in the range of -pi/2 through pi/2 
ceil 
Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer 
tan 
Returns the trigonometric tangent of an angle 
cos 
Returns the trigonometric cosine of an angle. Special cases: 
exp 
Returns Euler's number e raised to the power of a double value 
floor 
Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer 
log 
Returns the natural logarithm (base e) of a double value 
rint 
Returns the double value that is closest in value to the argument and is equal to a mathematical integer 
sin 
Returns the trigonometric sine of an angle 
sqrt 
Returns the correctly rounded positive square root of a double value 
tan 
Returns the trigonometric tangent of an angle