Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For example:

int $frame = 1;

where:

int $frameis the left side operand, in this case a variable.
=is the operator, in this case an assignment operator
1;is the right side operator, in this case the value assigned to the variable


The following sections show you how to work with operators:


Scroll only
scroll-viewporttrue
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-

...

docbooktrue
scroll-

...

eclipsehelptrue
scroll-

...

epubtrue
scroll-

...

htmltrue
2


Scroll pagebreak

Understand operator types

...

Scroll pagebreak

Arithmetic operators

Anchor
Arith
Arith

Arithmetic operators are symbols that represent mathematic functions.

...

Both statements accomplish the same results.

Scroll pagebreak

Arithmetic operator examples

...

  • Vectors
    The power (^) operator calculates the cross product of vectors, and the multiplication * operator calculates the dot product of vectors. For all other operators, each component of one vector is operated on by its counterpart component in the other vector.
    //Value: -4.000000, 2.000000, 0.000000
    vector $test = <<1, 2, 3>> ^ <<2, 4, 4>>;
    print ($test);
    Scroll pagebreak

Operator shortcut examples

...

Code Block
languagetext
// Declare variable
 int $inside = 1;
 
 // Shortcut for expression $inside = $inside + 9
 $inside += 9;
 
 // Shortcut for expression $inside = $inside –2
 $inside -= 2;
 
 // Shortcut for expression $inside = $inside 10
 $inside *= 10;
 print $inside;
 
 //declare variable
 vector $outside = <<2,2,2>>;
 
 // Shortcut for expression $outside += $outside + <<<<1,2,3>>
 $outside += <<1,2,3>>;
 print $outside;

Comparison operators

Anchor
Comparison
Comparison

Comparison operators are used to compare two values and evaluate whether a statement is true based on the relation of the value on the left to the value on the right and then execute the statement accordingly.

...

You can write a hook statement with a comparison operator using three operands.

Scroll pagebreak

Examples of comparison expressions

...

Code Block
languagetext
test condition ? operation1 : operation2
 int $markers = 5 < 9 ? 40 : 50; // Value: 40

Scroll pagebreak

Logical operators

Anchor
Logical
Logical

Logical operators are used to compare two values and evaluate whether a statement is true or false and then execute the statement accordingly. Logical operators create boolean results, that is, values of either TRUE or FALSE.

...

Code Block
languagetext
( ) [ ]
*/ % ^
+ -
< <= > >=
== !=
&&
||
?:
= += -= *= /=

Scroll pagebreak

Lowest precedence

Examples of when precedence effects the value of a statement:

Code Block
languagetext
//$front = (5 +(2*3))
int $front = 5 + 2 3
 
//$side = $side ((8 % 5) / 3)
int $back = 2 - 3 int (1 < 3);
 
//$side = $side ((8 % 5) / 3)
int $side = 2;
$side = 8 % 5 / 3;

...

Grouping operations for precedence

...