Siebel eScript Language Reference > Siebel eScript Commands > File I/O Methods in eScript >
Clib.freopen() Method
This method closes the file associated with a file pointer and then opens a file and associates it with the file pointer of the file that has been closed. Syntax
Clib.freopen(filename, mode, oldFilePointer)
|
|
filename |
The name of a file to be opened |
mode |
One of the file modes specified in the Clib.fopen() function; for Unicode, the same "u" flag as in Clib.fopen can be used |
oldFilePointer |
The file pointer to a file to be closed and to which filename is to be associated |
Returns
A copy of the old file pointer after reassignment, or null if the function fails. Usage
This method closes the file associated with oldFilePointer (ignoring any close errors) and then opens filename according to mode (as in Clib.fopen()) and reassociates oldFilePointer to this new file specification. It is commonly used to redirect one of the predefined file handles (stdout, stderr, stdin) to or from a file. Example
The following sample script writes to two different files using the same file pointer. var oFile = Clib.fopen("c:\\temp\\firstfile","w"); if (oFile == null) { TheApplication().RaiseErrorText("File not found."); } Clib.fprintf(oFile, "Writing to first file\n"); Clib.freopen("c:\\temp\\secondfile", "w", oFile); if (oFile == null) { TheApplication().RaiseErrorText("File not found."); } Clib.fprintf(oFile, "Writing to second file\n"); Clib.fclose(oFile);
See Also
Clib.getenv() Method Clib.fopen() Method
|