Function calls

Provides a reference for the shorthand syntax used with function calls in OPL.

Table 1. Syntactic shorthand
Syntax Shorthand for
++X X = X+1
X++ Same as ++X, but returns the initial value of X instead of its new value.
--X X = X-1
X-- Same as --X, but returns the initial value of X instead of its new value.
X += Y X = X + Y
X -= Y X = X - Y
X *= Y X = X * Y
X /= Y X = X / Y
X %= Y X = X % Y
X <<= Y X = X << Y
X >>= Y X = X >> Y
X >>>= Y X = X >>> Y
X &= Y X = X & Y
X ^= Y X = X ^ Y
X |= Y X = X | Y
Table 2. Function call syntax
Syntax Effect
function (arg1, ..., argn)

Calls function with the given arguments, and returns the result of the call.

Examples:

parseInt(field) writeln("Hello ", name) doAction() str.substring(start, start+length)

The function is typically either a script variable reference or a property access, but it can be any expression; the expression must yield a function value, or an error is signalled.

Examples:

callbacks[i](arg) // Calls the function in callbacks[i] "foo"() // Error: a string is not a function