contents   index   previous   next



Clib.freopen()

syntax:

Clib.freopen(filename, mode, filePointer)

where:

filename - a string with a filename to open.

 

mode - how or for what operations the file will be opened.

 

filePointer - pointer to file to use.

 

return:

number - file pointer on success, else null.

 

description:

This method closes the file associated with filePointer, ignoring any close errors, opens filename according to mode, as with Clib.fopen(), and reassociates filePointer with the new file specification. This method is commonly used to redirect one of the pre-defined file handles (stdout, stderr, or stdin) to or from a file.

 

The method returns a copy of the modified filePointer, or null if it fails.

 

The example code calls ScriptEase for DOS with no parameters, which causes a help screen to be printed, and redirects stdout to a file cenvi.out so that cenvi.out will contain the text of the ScriptEase help screens.

 

see:

Clib.fopen()

 

example:

if ( null == Clib.freopen("cenvi.out", "w", stdout) ) 

   Clib.printf("Error redirecting stdout\a\n")

else 

   Clib.system("SEDOS");

 


Clib.fscanf()