Siebel eScript Language Reference > C Language Library Reference > Clib File Input and Output Methods >

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)

Format B

Clib.fwrite(sourceVar, bytelength, filePointer)

Arguments

Table 151 describes the arguments for the Clib Write to File method.

Table 151. 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

Table 152 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.

Table 152. Relative Values of the varDescription and sourceVar Arguments
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 Format of the Data That the Clib Read From File Method Reads.

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

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