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

Clib Get Characters to Next Line Method


The CLib Get Characters to Next Line method returns one of the following values:

  • A string that includes the characters that exist in a file from the current position of the file cursor up to and including the next newline character.
  • If an error occurs or if it reaches the end of the file, then it returns the following value:

    Null

Format

Clib.fgets([maxLen,] filePointer)

Table 139 describes the arguments for the Get Characters to Next Line method.

Table 139. Arguments for the Get Characters to Next Line Method
Argument
Description

maxLen

The maximum length of the string that this method returns if it does not encounter a newline character.

If the File Mode is Unicode, then the maxLen argument is the length in Unicode characters.

If you do not specify the maxLen argument, then Siebel eScript uses the default limit of 999 characters.

filePointer

A file pointer that the Clib Open File method returns.

Example

The following example writes a string that contains an embedded newline character to a temporary file. To return and display the output, it then reads from the file twice:

function Test_Click ()
{
   var x = Clib.tmpfile();
   Clib.fputs("abcdefg\nABCDEFG\n", x);
   Clib.rewind(x);
   var msg = Clib.fgets(x) + " " + Clib.fgets(x);
   Clib.fclose(x);
   TheApplication().RaiseErrorText(msg);
}

This example produces the following output:

abcdefg
ABCDEFG

Caution About Using the Get Characters to Next Line Method with Non-ASCII Characters

If the string that the Get Characters to Next Line method returns includes a non-ASCII character, then you must configure Siebel CRM to open in Unicode the file that the filePointer argument specifies.

CAUTION:  If Siebel CRM opens the file in text mode, then this method treats any non-ASCII character it encounters as an end-of-line character and stops reading the current line. As a result, this method might truncate the string that it returns. If the file does not use an encoding standard that is compatible with Unicode, then you must first configure Siebel CRM to transform it to UTF-8 or UTF-16 with the appropriate byte-order mark (BOM) placed at the beginning of the file. For more information, see Clib Open File Method.

Related Topics

For more information, see Clib Write String to File Method.

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