Siebel eScript Language Reference > Using Siebel eScript > Using Operators in Siebel eScript >

Using a Shortcut Operation to Do an Arithmetic Operation


A shortcut operation is a combination of the equal operator (=) with another operator. You can use a shortcut operation to reduce the amount of code you write. This technique does the following:

  • To do an operation on the value that occurs to the left of the equal operator, it uses the value that occurs to the right of the equal operator.
  • Saves the result in the value that occurs to the left of the equal operator.

To use a shortcut operation to do an arithmetic operation

  • Add an operator immediately before the equal operator.

    For example, instead of writing i = i + 3, you can write i += 3.

Table 10 describes the shortcut operators that you can use in Siebel eScript.

Table 10. Shortcut Operators You Can Use in Siebel eScript
Shortcut Operation
Description

+=

Add a value to a variable.

-=

Subtract a value from a variable.

*=

Multiply a variable by a value.

/=

Divide a variable by a value.

%=

Return a remainder after a division operation.

The following example uses shortcut operators:

var i;
i += 3; //i is now 5 (2 + 3). Same as i = i + 3.
i -= 3; //i is now 2 (5 - 3). Same as i = i - 3.
i *= 5; //i is now 10 (2 * 5). Same as i = i * 5.
i /= 3; //i is now 3.333...(10 / 3). Same as i = i / 3.
i = 10; //i is now 10
i %= 3;  //i is now 1, (10 mod 3). Same as i = i % 3.

Siebel eScript Language Reference Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.