read_until

Gamma: Version 4.0
Prev |  | Next

# `read_until`

`read_until` -- reads characters, constructing a string as it goes.

## Syntax

    read_until (file, delimiters)

## 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.

`delimiters`

  A string of delimiter characters. "" indicates white space.

## Returns

All characters in the file up to the first occurrence of any of `delimiter` characters, or "Unexpected end of file".

## Description

This function reads characters from the input file one at a time until it reaches any of the `delimiter` characters, constructing a string as it goes. Successive calls continue from the point of the previous `read_until`. If the end of file is reached, the function returns "Unexpected end of file".

## Example

An input file contains the following:

              Lists can be
              expressed as (a b c).

Successive calls to `read_until` will produce:

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

## See Also

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

Prev | Home | Next
`read_n_chars` | Up | `seek`

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