4.20 Term reading and writing
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Term reading and writing
          • write_term/2
          • write_term/3
          • write_length/3
          • write_canonical/1
          • write_canonical/2
          • write/1
          • write/2
          • writeq/1
          • writeq/2
          • writeln/1
          • writeln/2
          • print/1
          • print/2
          • portray/1
          • read/1
          • read/2
          • read_clause/3
          • read_term/2
          • read_term/3
          • read_term_from_atom/3
          • read_term_with_history/2
          • prompt/2
          • prompt1/1
    • Packages
Availability:built-in
Sourceread_term_with_history(-Term, +Options)
Read a term while providing history substitutions. read_term_with_history/2 is used by the top level to read the user's actions. In addition to the options recognised by read_term/2, the following options are recognised:
prompt(+Prompt)
Define the prompt to use. The default is ~! ?-. A sequence ~! is replaced by the current history event number.
show(+Command)
Using Command lists the saved history events. Default is !history.
help(+Command)
Using Command shows help on the history system. Default is !help.
no_save(+Commands)
Do not save the command into the history if it appears in the list Commands.
module(+Module)
Defines the module from which to extract module-specific syntax such as operators and handling of the various quotes. Default is the typein module which is set using module/1 and is initially set to user.
input(+Stream)
Stream from which to read Term. Default is user_input.

Most applications will use the read_term/2 option variable_names to get access to the names of the variables in Term. SWI-Prolog calls read_term_with_history/2 as follows:

    read_term_with_history(
        Goal,
        [ show(h),
          help('!h'),
          no_save([trace, end_of_file]),
          prompt('~! ?-'),
          variable_names(Bindings)
        ]).