Siebel eScript Language Reference > Siebel eScript Commands > File I/O Methods in eScript >

Clib.fwrite() Method

This method writes the data in a specified variable to a specified file and returns the number of elements written.

Syntax A

Clib.fwrite(sourceVar, varDescription, filePointer)

Syntax B

Clib.fwrite(sourceVar, bytelength, filePointer)



Number of bytes to write


A variable indicating the source from which data is to be written


A value depending on the type of object indicated by sourceVar


A file pointer as returned by Clib.fopen()


0 if a write error occurs; use Clib.ferror() to get more information about the error.


This method writes the data in sourceVar to the file indicated by filePointer and returns the number of elements written.

The varDescription variable describes how much data is to be read from the object indicated by sourceVar:

If sourceVar Is
Value of varDescription Is


Length of the buffer


Object descriptor

A single datum

One of the values listed in Clib.fread() Method

The Siebel eScript version of fwrite() differs from the standard C version in that the standard C library is set up for writing arrays of numeric values or structures from consecutive bytes in memory. This is not necessarily the case in eScript.


To write the 16-bit integer i, the 32-bit float f, and the 10-byte buffer buf into open file fp, use the following code:

if ( !Clib.fwrite(i, SWORD16, fp) || !Clib.fwrite(f, FLOAT32, fp)
            || 10 != fwrite(buf, 10, fp))
   TheApplication().RaiseErrorText("Error writing to file.\n");

See Also

Clib.fread() Method

Siebel eScript Language Reference