CommaIo.writeExp Method
Writes the content of a container to a file.
Syntax
public boolean writeExp(container data)
Run On
Called
Parameters
- data
Type: container
The container that holds data for the record.
Return Value
Type: boolean
true if the operation succeeds; otherwise, false. If the operation fails, you can check the status to learn the cause of the failure.
Remarks
The entries in the container are treated as fields. The container itself is treated as a full record.
Fields are separated by the delimiter that is specified by using the outFieldDelimiter method. Records are separated by the delimiter that is specified by using the outRecordDelimiter method.
Examples
This example uses a CommaIO object to read from the example file.
{
container c;
CommaIo myfile;
FileIoPermission perm;
#define.ExampleFile(@"c:\myfile.txt")
#define.ExampleOpenMode("w")
// Set code access permission to help protect the use
// of CommaIO.new
perm = new FileIoPermission(#ExampleFile, #ExampleOpenMode);
perm.assert();
myfile = new CommaIo(#ExampleFile, #ExampleOpenMode);
// Assign the entries in the container according to record layout.
c = [1,"MyText",1.324,"Last field"];
// Write this record according to file format
// (record/field delimiters).
myfile.writeExp(c);
// Close the code access permission.
CodeAccessPermission::revertAssert();
}
See Also
CommaIo.outFieldDelimiter Method