Miscellaneous functions
Provides a reference of miscellaneous functions in IBM ILOG Script.
| Syntax | Effect |
|---|---|
| stop() | Stops the execution of the program at the current statement and, if the debugger is enabled, enters debug mode. |
|
Converts the arguments to strings and prints them to the current debug output. The
implementation depends on the application in which IBM ILOG Script is embedded. The function
writeln prints a newline at the end of the output, while write
does not. See the note on writeLine in this topic. |
| loadFile(string) | Loads the script file whose path is string.
The path can be either absolute or relative. If this path does not
designate an existing file, the file is looked up using a method that
depends on the application in which the script is embedded. Typically,
a file with the name string is searched for in a
list of directories specified in the application setup. |
| includeScript(string)
For use in OPL. |
Loads the script file whose path is string.
The path can be either absolute or relative. If this path does not
designate an existing file, the file is looked up using a method that
depends on the application in which the script is embedded. Typically,
a file with the name string is searched for in a
list of directories specified in the application setup.The effect
of this function is the same as for |
| eval(string) | Executes Examples: eval("2*3") -> 6 eval("var i=0; for (var j=0; j<100; j++) i=i+j; i") -> 4950 n=25; eval("Math.sqrt(n)") -> 5 eval("function foo(x) { return x+1 }") -> error |
| fail() | Stops the execution of the scripting block at the current statement, reports an error, and goes on. Example: execute b1 { writeln("A"); fail(); writeln("B"); } execute b2 {writeln("C"); } gives A C as the output and reports an error line 4 Scripting runtime error: fail() called. |
- If the number is nan, it will return "NaN"
- If the number is infinity => "Infinity"
- If the number is 0.0 => "0"
- If the number has the value of an integer, then the string is the same as if it were printed
using
sprintf("%d"). If the integer has an absolute value bigger than 2147483647, then it is replaced by +2147483647 or -2147483647 before printing. Note that this also applies to integers that are specified as floating point numbers, like, for example, 1e75. - If the number is a fractional number, then the display format depends on the absolute value of the number. If the absolute value is in [1e-6, 1e10], then the number is displayed with 9 decimal digits. Otherwise, it is printed in scientific format.
The precision setting of OPL can only control printing performed by OPL: writeln of objects, printInternalData, printExternalData. There is no precision control for writeln of primitives.
execute{
writeln(0);
writeln(0.0);
writeln(0.567);
writeln(-0.567);
writeln(-20.0);
writeln(-20);
writeln(-5.123456786742);
writeln(-200000000000);
writeln(-200000000000.5);
writeln(0.000002340);
}
will output
0
0
0.567
-0.567
-20
-20
-5.123456787
-2147483648
-2.000000000e+11
2.340000000e-06
>>