IBM Tivoli Software IBM Tivoli Software

[ Bottom of Page | Previous Page | Next Page | Contents | Index ]


read

Read a Prolog term from an open Prolog source file.

Synopsis

read(_file, _term)

Description

The term _term is unified with the next term read from the file _file. Characters are read from the input file until an end-point is found (a period character followed by an end-of-line character) or until an error is encountered. This predicate is for reading Prolog terms only. See readln for reading arbitrary text data.

Arguments

_file
The file pointer obtained from opening the file with the fopen predicate.
_term
The Prolog term read from the file.

Examples

The following example Tivoli Enterprise Console rule fragment shows how to open a Prolog source file that contains Prolog terms and read a term into a variable. Assume this example reads from the file named /var/prolog/tec_r.nt_hosts, which contains the following clauses:

nt_hosts('hmckinne').
nt_hosts('scary').

The actions for the rule to read the first term from the file is shown following:

action: open_and_read: (
  fopen(_fp, '/var/prolog/tec_r.nt_hosts', 'r'),

  read(_fp, _term)
  % _term is unified with nt_hosts(hmckinne).
),
action: close_file: (
  fclose(_fp)
)

See Also

readln


[ Top of Page | Previous Page | Next Page | Contents | Index ]