Default values

Lists the default values used in OPL.

Table 1. Default value syntax
Syntax Effect

with

(expression)

statement

Evaluate expression, then execute statement with the value of expression temporarily installed as the default value.

When a reference to an identifier name in statement is evaluated, this identifier is first looked up as a property of the default value; if the default value does not have such a property, name is treated as a regular variable.

For example, the following program displays "The length is 3", because the identifier length is taken as the length property of the string "abc".

with ("abc") { writeln("The length is ", length) }

You can nest with statements; in this case, references to identifiers are looked up in the successive default values, from the innermost to the outermost with statement.