Method Description
Binary.open()
Open a file or directory
Syntax
void = Binary.open(filename, mode)
Parameters
The 'Binary.open' method takes 2 parameters:
Name | Type/Value | Range/Length | Description | filename | string | | Required. The name of the file or directory to open | mode | number | | Optional, default = modeRead How to open this file |
Results
The 'Binary.open' method returns no useful information.
Remarks This method opens a named file or directory. The default location for the file
is in the file space for the current virtual server. Directories are treated like files - and one openned successive calls to
'readln' will return the name of one file within the directory The only mode under which a directory can be opennned is for reading. Values for the 'mode' parameter are available as attributes on the binary object itself. This
is best illustrated by example:
<rb:script>
var fileObj = new Binary;
if (fileObj.open('/myfile.txt',fileObj.modeWrite)) {
fileObj.writeln("Hello World");
}
</rb:script>
The mode value is a bitwise 'OR' of one or more of the following flags: - obj.modeRead open for reading (the default)
- obj.modeWrite open for writing. Contents of the file are over-written.
- obj.modeAppend open for writing. New data is written to the end of the existing file.
- obj.modeBinary If this flag is set then the file is openned in binary mode and no newline processing takes place.
Note that the model for the system supports multiple underlying file systems. |