read_line


read_line(s = current_reader(),
          separator = \newline,
          include_separator = false,
          max_length = false)
      

Read all the characters, upto the separator character, from the textual input stream s. Return these characters as a single string. Return the eof object if end-of-stream has reached. The separator character defaults to \newline.

If it is specified, max_length must be a nonnegative exact integer and it places an upper limit on the number of characters that are read.

Separator is included at the end of the string only if it was the last character read and include_separator is true.

If separator is false, all the characters until the end-of-stream will be read.

Examples:


// Read and print each line from a file of comma-separated-values:          
let grades = file_reader("stud_grades.csv")
letseq loop (line = read_line(grades))
  when (not(is_eof_object(line)))
  { showln(line)
    loop(read_line(grades)) }

//> 1,CS-101,A+
    2,ART-166,A
    3,STAT-103,B
    ...
close_reader(grades)

// To read each element in the file, call `read_line(grades, \,)`.
      

Also see:

read
read_all
read_all_chars
read_n_chars
read_char
peek_chars
read_all_bytes
read_n_bytes
read_byte


Core Module Index | Contents