Initial revision
[LeanCalc.git] / help / fgetline
1 NAME
2     fgetline - read the next line from a file, newline is tossed
3
4 SYNOPSIS
5     fgetline(fd)
6
7 TYPES
8     fd          file
9
10     return      str or nil
11
12 DESCRIPTION
13     This function reads the next line, including any trailing newline from
14     the open file associated with fd.  Unlike fgets, the trailing
15     newline is removed from the return string.
16
17     Empty lines return the null string.  When the end of file is reached,
18     fgetline returns the null value.  (Note the distinction between a null
19     string and a null value.)
20
21     If the line contained a numeric value, then the 'eval' function can
22     then be used to convert the string to a numeric value.
23
24     If a line is read, is returned minus the trailing newline, otherwise
25     (EOF or ERROR) nil is returned.
26
27 EXAMPLE
28     > fd = fopen("/tmp/newfile", "w")
29     > fputs(fd, "chongo was here\n")
30     > fputs(fd, "123\n")
31     > fd2 = fopen("/tmp/newfile", "r")
32     > fgets(fd2)
33             "chongo was here
34     "
35
36     > fclose(fd2)
37     > fd2 = fopen("/tmp/newfile", "r")
38     > fgetline(fd2)
39             "chongo was here"
40     > eval(fgetline(fd2))
41             123
42
43 LIMITS
44     fd must be associated with an open file
45
46 LINK LIBRARY
47     none
48
49 SEE ALSO
50     errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen,
51     fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt
52