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)
The following table describes the 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
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.
Related Topics
For more information, see Clib Write String to File Method.