Siebel eScript Language Reference > C Language Library Reference > Clib File and Directory Methods >

Clib Reopen File Method


The Clib Reopen File method closes the file associated with a file pointer. It then opens a file and associates it with the file pointer of the file that it closed. You can use it to redirect one of the predefined file handles to a file or from a file. These file handles include stdout, stderr, and stdin. It returns one of the following values:

  • If successful, then it returns a copy of the old file pointer.
  • If not successful, then it returns the following value:

    Null

Format

Clib.freopen(filename, mode, oldFilePointer)

Table 129 describes the arguments for the Clib Reopen File method.

Table 129. Arguments for the Clib Reopen File Method
Argument
Description

filename

The name of the file that this method opens.

mode

One of the file modes specified in Clib Open File method. For Unicode, you can use the same u flag that you can use in the Clib Open File method.

oldFilePointer

The file pointer to the file that the Clib Reopen File method closes and where it associates the file that you specify in the filename argument.

Example

The following example uses the same file pointer to write to two different files:

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);

Related Topics

For more information, see the following topics:

Siebel eScript Language Reference Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.