12.9.3.1 Writing Prolog terms to foreign streams
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • Foreign access to Prolog IO streams
          • Interacting with foreign streams
            • Writing Prolog terms to foreign streams
              • PL_write_term()
    • Packages
Availability:C-language interface function
int PL_write_term(IOSTREAM *s, term_t term, int precedence, int flags)
Write term to s. precedence is the initial operator precedence, typically 1200. flags is a bitwise or of the constants below. These flags map to options for write_term/2.
PL_WRT_QUOTED
PL_WRT_IGNOREOPS
PL_WRT_NUMBERVARS
PL_WRT_PORTRAY
PL_WRT_CHARESCAPES
PL_WRT_NO_CHARESCAPES
The PL_WRT_NO_CHARESCAPES does not map to a write_term/2 option. If one of PL_WRT_CHARESCAPES or PL_WRT_NO_CHARESCAPES is specified, character escapes are (not) applied. If neither is specified the default depends, like for write/1, on the character_escapes flag on the module user.243Prior to version 9.1.6 the default (no flag) was to escape the quotes and the backslash (\).
PL_WRT_BACKQUOTED_STRING
PL_WRT_ATTVAR_IGNORE
PL_WRT_ATTVAR_DOTS
PL_WRT_ATTVAR_WRITE
PL_WRT_ATTVAR_PORTRAY
PL_WRT_BLOB_PORTRAY
PL_WRT_NO_CYCLES
PL_WRT_NEWLINE
PL_WRT_VARNAMES
PL_WRT_BACKQUOTE_IS_SYMBOL
PL_WRT_DOTLISTS
PL_WRT_BRACETERMS
PL_WRT_NODICT
PL_WRT_NODOTINATOM
PL_WRT_NO_LISTS
PL_WRT_RAT_NATURAL
PL_WRT_CHARESCAPES_UNICODE
PL_WRT_QUOTE_NON_ASCII
PL_WRT_PARTIAL

For example, to print a term to user_error as the toplevel does, use

    PL_write_term(Suser_error, t, 1200,
                  PL_WRT_QUOTED|PL_WRT_PORTRAY|
                  PL_WRT_VARNAMES|PL_WRT_NEWLINE)