read_line

Gamma: Version 4.0
Prev |  | Next

# `read_line`

`read_line` -- reads a single line of text.

## Syntax

    read_line (file)

## Arguments

`file`

  A file pointer to a previously opened file. This may be either a file in the file system, or a string opened for read and write.

## Returns

All characters in the file up to the first newline character, as a string. If the end of file is reached, returns "Unexpected end of file".

## Description

This function reads a single line of text from the given file, up to the first newline character, regardless of Lisp syntax. This allows a programmer to deal with text files constructed by other programs.

## Example

An input file contains the following:

              Lists can be
              expressed as (a b c).

Successive calls to `read_line` will produce:

        Gamma> ft = open ("myreadlfile.dat", "r");
        #<File:"myreadlfile.dat">
        Gamma> read_line(ft);
        "Lists can be"
        Gamma> read_line(ft);
        "expressed as (a b c)."
        Gamma> read_line(ft);
        "Unexpected end of file"
        Gamma>

See the Common: The Text Message Display section of the Controller Functions chapter, or the GTK: Displaying Query Data section or the Photon: Displaying Query Data section of the History Functions chapter in the Cogent Tools Demo and Tutorials book for examples of this function used in context.

## See Also

`read`, `read_char`, `read_double`, `read_float`, `read_long`, `read_short`, `read_until`

Prev | Home | Next
`read_eval_file` | Up | `read_n_chars`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.