UOX3 Script Engine

Functions, Methods, Properties and Event handling

File I/O Methods


Open( string filename, string accessMethod );
PurposeOpens a file for reading, writing or appending.
NotesaccessMethod is a one byte string, which contains either "a" (append), "r" (read) or "w" (write).
Example of Usage
var mFile = new UOXCFile;
mFile.Open( "test.dat", "a" );


PurposeCloses a file that is currently open.
NotesClosing an unopened file is undefined.
Example of Usage


Write( string toWrite );
PurposeWrites a string out to the file.
NotesA file cannot be longer than 1MB in size. If opened for reading, this will not work.
Example of Usage
mFile.Write( "Hello cruel world\n" );


string Read( int numBytes );
PurposeReturns a string of length numBytes, reading numBytes from the opened file.
NotesnumBytes must be at least 1 and less than or equal to 512.
Example of Usage
var mLine = mFile.Read( 80 );


string ReadUntil( string delimeter );
PurposeReads a string until it encounters a newline or the string specified by delimeter.
Notesdelimiter is at most a 2 character string (for C style character escapes, where \n is a newline, \' is a quote and so on).
Will not read more than 512 bytes.
Example of Usage
var untilT = mFile.ReadUntil( "t" );
// reads a line until it hits the letter t, a newline, or 512 bytes in length.


PurposeDeallocates the memory associated with creating the variable.
NotesThis must be called otherwise a slow memory leak will occur.
Example of Usage

File I/O Properties

Property Purpose
pos (read/write) The current position that you are at in the file. This property can be read and set, where setting it moves relative to the start of file (ie if you set it to 5, it would be 5 bytes from the start, not 5 bytes from it's current location). You cannot seek a location if you have opened the file for append.
length (read) The length of the file
eof (read) A boolean value returning true if the file pointer is at the end of the file.


ęCopyright 2000-2001 WWW.UOX3.NET (Daniel Stratton/Matthew Randall)