Did you know ... Search Documentation:
readutil.pl -- Read utilities
PublicShow source

This library provides some commonly used reading predicates. As these predicates have proven to be time-critical in some applications we moved them to C. For compatibility as well as to reduce system dependency, we link the foreign code at runtime and fallback to the Prolog implementation if the shared object cannot be found.

See also
- library(pure_input) allows for processing files with DCGs.
Source read_line_to_codes(+In:stream, -Line:codes) is det
Read a line of input from In into a list of character codes. Trailing newline and or return are deleted. Upon reaching end-of-file Line is unified to the atom end_of_file.
Source read_line_to_codes(+Stream, -Line, ?Tail) is det
Read a line of input as a difference list. This should be used to read multiple lines efficiently. On reaching end-of-file, Tail is bound to the empty list.
Source read_line_to_string(+Stream, -String) is det
Read the next line from Stream into String. String does not contain the line terminator. String is unified with the atom end_of_file if the end of the file is reached.
See also
- read_string/5 can be used to read lines with separated records without creating intermediate strings.
Source read_stream_to_codes(+Stream, -Codes) is det
Source read_stream_to_codes(+Stream, -Codes, ?Tail) is det
Read input from Stream to a list of character codes. The version read_stream_to_codes/3 creates a difference-list.
Source read_file_to_codes(+Spec, -Codes, +Options) is det
Read the file Spec into a list of Codes. Options is split into options for absolute_file_name/3 and open/4. In addition, the following option is provided:
tail(?Tail)
Read the data into a difference list Codes\Tail.
See also
- phrase_from_file/3 and read_file_to_string/3.
Source read_file_to_string(+Spec, -String, +Options) is det
Read the file Spec into a the string String. Options is split into options for absolute_file_name/3 and open/4.
See also
- phrase_from_file/3 and read_file_to_codes/3.
Source read_file_to_terms(+Spec, -Terms, +Options) is det
Read the file Spec into a list of terms. Options is split over absolute_file_name/3, open/4 and read_term/3. In addition, the following option is processed:
tail(?Tail)
If present, Terms\Tail forms a difference list.

Note that the `output' options of read_term/3, such as variable_names or subterm_positions will cause read_file_to_terms/3 to fail if Spec contains multiple terms because the values for the different terms will not unify.

Source read_stream_to_codes(+Stream, -Codes) is det
Source read_stream_to_codes(+Stream, -Codes, ?Tail) is det
Read input from Stream to a list of character codes. The version read_stream_to_codes/3 creates a difference-list.