Professional Documents
Culture Documents
FILEIO
FILEIO
FILEIO
In this example, we created a new instance and stored it in the variable myFile.
Next, the displayOpen() method is used to display an open dialog to allow a file
to
be chosen. The file is returned as a fully-qualified path string to Lingo. The f
ile
is then opened in read only mode, the contents of the file are read, and the fil
e is
closed. Lastly, the instance is disposed of.
Known Problems
==============
The createFile() method does not support relative filenames, or the Lingo '@'
operator in pathnames. This will be fixed in a later version.
The displaySave() method does not directly inform Lingo whether a user is
replacing an existing file. The workaround is to attempt to create the file usin
g
createFile() and check the error code for a "File Already Exists" error.
History
=======
09dec97 (v1.0.4)
Fixed a problem leading to garbage characters appearing at the ends of lines,
or possibly crash.
18apr97 (v1.0.2)
Fixed parenting problem with displaySave() and displayOpen() methods.
Added support for Authorware.
27may96 (v1.0.1)
Added support for double-byte character sets.
Added version() method to report FileIO Xtra version information.
Added getOSDir() to return a full path to the Windows Directory/System Folder.
15mar96 (v1.0.0 Beta)
First public release.
Method Reference
================
The first line of each definition contains the method name, a list of parameters
and
thier value types. The internal name of the FileIO Xtra is "fileio". This name i
s
used whenever referencing the xtra using the form 'xtra "fileio"'.
Note that while Director and projector's can use net-based files by supplying a
URL
for a filename, the FileIO Xtra cannot. It is limited to accessesing files avail
able
via filesystems mounted on the local system.
New methods will appear at the bottom of this list.
--mMessageList( xtra reference )
Returns a list of methods and parameters, as well as a brief explanation of each
.
comma seperated string of file types and associated extensions (e.g. "All
Files,*.*,Text Files,*.TXT"), and a string of types on the Macintosh (e.g.
"TEXTPICT"). On Windows, the filter mask string is limited to 256 characters. On
the
Macintosh, you are limited to four four-character types. When a new instance of
FileIO is created, the filter masks defaults to all files. To reset the filter m
ask to
display all files after it has been set, just pass in an empty string (e.g.
setFilterMask(me, "")).
--openFile( instance, string fileName, int openMode )
Opens the named file. This call must be used before any read/write operations ca
n
take place. The filename can be either a fully-qualified path and filename, or a
relative filename. The Lingo '@' pathname operator is supported. The openMode
parameter specifies whether to open the file in Read, Write or ReadWrite mode. V
alid
Flags are: 0 Read/Write, 1 Read, 2 Write.
--closeFile( instance )
Closes a file that has been previously opened using the openFile() method.
--displayOpen( instance )
Displays a platform specific Open dialog allowing a user to specify a file. Retu
rns a
fully-qualified path and fileName to Lingo. The setFilterMask() method can be us
ed to
control what file types are displayed in the dialog.
--displaySave( instance, string title, string defaultFileName )
Displays a platform specific Save dialog allowing a user to specify a file. Retu
rns a
fully-qualified path and fileName to Lingo. The setFilterMask() method can be us
ed to
control what file types are displayed in the dialog. The string and defaultFileN
ame
parameters allow you to specifiy a default filename to be displayed, as well as
title
text for the save dialog.
--createFile( instance, string fileName )
Creates a file. The fileName must be either a fileName to be created in the curr
ent
directory, or a fully-qualified path and fileName. The Lingo '@' pathname operat
or
and relative paths are not supported. After creating the new file, the file must
be
opened before it can be written to.
--setPosition( instance, position )
Sets the file position of the current open file. The file must be open to use th
is
method.
--getPosition( instance )
Gets the file position of the current open file. Returned as an integer. The fil
e
must be open to use this method.
--getLength( instance )
Gets the length of the currently opened file. Returned as an integer. The file m
ust
be open use this method. The value returned is the length of the file in bytes.
--writeChar( instance, string theChar )
Writes a single character to the file at the current position. The file must be
open
in write or read/write mode to use this method.
--writeString( instance, string theString )
Writes a string to the file at the current position. The file must be open in wr
ite
or read/write mode to use this method.
--readChar( instance )
Reads the character (either single or double-byte) at the current position and t
hen
increments the position. The character is returned to Lingo as a string. The fil
e must
be open in read or read/write mode to use this method.
--readLine( instance )
Reads from the current position up to and including the next CR, increments the
position, and returns the string to Lingo. The file must be open in read or