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

Clib Read From File Method


The Clib Read From File method reads data from an open file that you specify in the filePointer argument. It then stores this data in an argument, buffer, or BLOB that you specify. If this argument, buffer, or BLOB does not exist, then this method creates it. It returns one of the following values:

  • If successful, then it returns the number of elements it read.
  • If you specify the destBuffer argument, then it returns the number of bytes read, up to the value you specify in the bytelength argument.
  • If you specify the varDescription argument, then it returns one of the following values:
    • 1 if it reads the data
    • 0 if a read error occurs or if it encounters the end of file
Format A

Clib.fread(destBuffer, bytelength, filePointer)

Format B

Clib.fread(destVar, varDescription, filePointer)

Format C

Clib.fread(blobVar, blobDescriptor, filePointer)

Arguments

Table 141 describes the arguments for the Clib Read From File method.

Table 141. Arguments for the Clib Read From File Method
Argument
Description

destBuffer

The buffer to contain the data that this method reads.

bytelength

The number of bytes that this method reads.

filePointer

A file pointer that the Clib Open File method returns.

destVar

A container to hold the data that this method reads.

varDescription

The format of the data that this method reads. For more information, see Format of the Data That the Clib Read From File Method Reads.

blobVar

The BLOB where this method writes data.

blobDescriptor

The BLOB descriptor for the value you specify in the blobVar argument.

Format of the Data That the Clib Read From File Method Reads

Table 142 describes the format of the data that the Clib Read From File method reads. You specify this format in the varDescription argument. If the destVar argument must hold a single datum, then you must set the varDescription argument to one of these formats. If the destVar contains blob data, then you must specify a blobdescriptor argument. A blobdescriptor can also consist of varDescriptions for the individual elements of the blobdescriptor.

Table 142. Format of the Data That the Clib Read From File Method Reads
Value
Description

UWORD8

Stored as an unsigned byte.

SWORD8

Stored as a signed byte.

UWORD16

Stored as an unsigned, 16-bit integer.

SWORD16

Stored as a signed, 16-bit integer.

UWORD24

Stored as an unsigned, 24-bit integer.

SWORD24

Stored as a signed, 24-bit integer.

UWORD32

Stored as an unsigned, 32-bit integer.

SWORD32

Stored as a signed, 32-bit integer.

FLOAT32

Stored as a floating-point number.

FLOAT64

Stored as a double-precision, floating-point number.

The following code includes example formats:

ClientDef = new blobDescriptor();
ClientDef.Sex = UWORD8;
ClientDef.MaritalStatus = UWORD8;
ClientDef._Unused1 = UWORD16;
ClientDef.FirstName = 30; ClientDef.LastName = 40;
ClientDef.Initial = UWORD8;

Usage for the Clib Read From File Method

The Siebel eScript usage of fread differs from the standard C library usage in that the C library reads an array of numeric values or structures into consecutive bytes in memory. The Clib Read From File method reads data in the byte-order that the current value of the BigEndianMode global variable describes.

Example

The following example reads the following items from the fp file:

  • Reads the 16-bit i integer
  • Reads the 32-bit f float
  • Reads the 10-byte buffer from the buf buffer:

    if ( !Clib.fread(i, SWORD16, fp) || !Clib.fread(f, FLOAT32, fp)
    || 10 != Clib.fread(buf, 10, fp) )
       TheApplication().RaiseErrorText("Error reading from file.\n");
    }

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