Chapter 3 DynaScript Predefined Objects
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".
To use a file property:
file.propertyName
To use a file method:
file.MethodName( parameter )
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.
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();
-->
Copyright © 1999 Sybase, Inc. All rights reserved. |