Chapter 3 DynaScript Predefined Objects


file object

Object

Provides manipulation of files through the file system. These are files external to the Web site.

For information on manipulating documents internal to the Web site, see "site object".

Syntax

To use a file property:

file.propertyName

To use a file method:

file.MethodName( parameter ) 

Description

To manipulate a file, a file object is created to represent the file. To create a file object, use the file constructor. The syntax to create a new file object is:

fileObj = new File( fileName, accessMode);

The specified file is opened using the access mode provided, and a file object representing the open file is returned.

Example

This example reads information from FILE_A.DAT and adds it to the end of FILE_B.DAT, converting all tabs to spaces:

<!--SCRIPT 
ifile = new File( "FILE_A.DAT", "r" );
ofile = new File( "FILE_B.DAT", "a" );
for( ch = ifile.ReadChar(); !ifile.eof; ch = ifile.ReadChar() ) {
if( ch == "\t" ) {
ofile.Write( " " );
} else {
ofile.Write( ch );
}
}
ifile.Close();
ofile.Close();
-->

See also

"name property".

"mode property".

 


Copyright © 1999 Sybase, Inc. All rights reserved.