IloOplOutputFile
See the Overview for a general presentation of the ILOG Script extensions for OPL.
execute {
var f = new IloOplOutputFile("output.txt");
f.writeln("Hello World"); // lazy open
f.close();
var f2 = new IloOplOutputFile("output.txt", true);
if (f2.exists)
writeln("output.txt exists ==> append mode");
else
writeln("output.txt doesn't exist");
f2.writeln("another line");
f2.close();
}output.txt in the directory where the .mod file
is located. After execution the Scripting log shows:output.txt exists ==> append mode
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
IloOplOutputFile(path, append)
|
| Field Attributes | Field Name and Description |
|---|---|
| flow control | |
| flow control |
| Method Attributes | Method Name and Description |
|---|---|
| flow control |
close()
Closes the output file.
|
| flow control |
open(path)
Opens the file on the given path.
|
| flow control |
write(text, textN)
Writes a string to the output file.
|
| flow control |
writeln(text, textN)
Writes one line to the output file.
|
write() invocations will cause an error.
Closing a previously-closed file, however, has no effect.