Skip to main content
PREV CLASS NEXT CLASS FRAMES NO FRAMES

 

Class IloOplOutputFile

IloOplOutputFile

Description:

See the Overview for a general presentation of the ILOG Script extensions for OPL.

Example:
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();
}
The script creates the file output.txt in the directory where the .mod file is located. After execution the Scripting log shows:
output.txt exists ==> append mode
Iterating properties:
Empty iteration.
Index resolution:
Default behavior.
Available for:
flow control

Constructor Summary
Constructor Attributes Constructor Name and Description
 
IloOplOutputFile(path, append)
Property Summary
Field Attributes Field Name and Description
flow control
flow control
Method Summary
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.
Constructor Detail
IloOplOutputFile
IloOplOutputFile(path, append)
Parameters:
path - Optional: The path of the file to open.
append - Optional: If true, sets the stream position at the end of the file.
Property Detail
exists
{boolean} exists
Available for:
flow control

isOpen
{boolean} isOpen
Deprecated:
replaced by exists
Available for:
flow control
Method Detail
close
close()
Closes the output file. Once a file has been closed, further write() invocations will cause an error. Closing a previously-closed file, however, has no effect.
Available for:
flow control

open
open(path)
Opens the file on the given path.
Parameters:
path - The path of the file to open.
Deprecated:
The file is automatically opened when needed.
Available for:
flow control

write
write(text, textN)
Writes a string to the output file.
Parameters:
text - Writes the contents of this string.
textN - Optional, n strings
Available for:
flow control

writeln
writeln(text, textN)
Writes one line to the output file.
Parameters:
text - Writes the contents of this string and ends with a new line.
textN - Optional, n strings.
Available for:
flow control

©Copyright IBM Corp. 1987-2011.