![]() |
![]() |
[ Bottom of Page | Previous Page | Next Page | Contents | Index ]
read(_file, _term)
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.
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) )
[ Top of Page | Previous Page | Next Page | Contents | Index ]