Clib Write to File Method
The Clib Write to File method writes data to a file. It returns one of the following values:
If successful, then it returns the number of elements it wrote
If not successful, then it returns the following value:
0
Siebel eScript usage of fwrite differs from the standard C library usage. The C library writes arrays of numeric values or structures from consecutive bytes in memory. This is not necessarily true in Siebel eScript.
Format A
Clib.fwrite(sourceVar, varDescription, filePointer)
Clib.fwrite(sourceVar, bytelength, filePointer)
The following table describes the arguments for the Clib Write to File method.
Argument | Description |
---|---|
bytelength |
Number of bytes that this method writes. |
sourceVar |
The source that this method uses to get the data that it writes. |
varDescription |
A value that depends on the type of object that the sourceVar argument identifies. |
filePointer |
The file where this method writes data. |
Usage for the varDescription Argument
The following table describes values you must set for the sourceVar argument and the varDescription argument. For example, if you use the sourceVar argument to identify a buffer, then you must set the varDescription argument to the length of that buffer, in bytes.
Value of the sourceVar Argument |
Value of the varDescription Argument |
---|---|
Buffer |
Length of the buffer, in bytes. |
Object |
Value of the object descriptor. |
A single datum |
One of the values listed in Clib Read From File Method. |
Example
The following example writes the following data into the fp file:
The 16-bit i integer
The 32-bit f float
The 10-byte buf buffer:
if ( !Clib.fwrite(i, SWORD16, fp) || !Clib.fwrite(f, FLOAT32, fp)
|| 10 != fwrite(buf, 10, fp))
{
TheApplication().RaiseErrorText("Error writing to file.\n");
}