Siebel eScript Language Reference > Siebel eScript Commands > File I/O Methods in eScript >
Clib.fgets() Method
This method returns a string consisting of the characters in a file from the current file cursor to the next newline character. Syntax
Clib.fgets([maxLen,] filePointer)
|
|
maxLen |
The maximum length of the string to be returned if no newline character is encountered; if the File Mode is Unicode, the length parameter is the length in Unicode characters. If you do not specify maxLen, then eScript uses the default limit of 999 characters. |
filePointer |
A file pointer as returned by Clib.fopen(). |
Returns
A string consisting of the characters in a file from the current file cursor to the next newline character. If an error occurs, or if the end of the file is reached, null is returned. Usage
This method returns a string consisting of the characters in a file from the current file cursor to the next newline character. The newline is returned as part of the string. Example
This example writes a string containing an embedded newline character to a temporary file. It then reads from the file twice to retrieve the output and display it. 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); }
Running this code produces the following result. abcdefg ABCDEFG
See Also
Clib.fputs() Method
|