How do I make a line wrap using print/1 in the console window?

I’m using: SWI-Prolog version 8.1.9.

Up until now I’ve been using write/1 and nl/0 to generate console output. Now I am using print/1 since I am experimenting with portray/1. I tried using:

print('\n')

To wrap to a new line like nl/0 does, but instead I see the literal string \n in the console output.

How can I get console output to wrap using print/1?

Also, I noticed that when I toggle output to a file using the protocol/0 command, my portray/1 predicates no longer get called and I see the plain dump of the term in the generated trace log file instead of my formatted print of the portrayed term. How can I get portray/1 to work while I am outputting trace/console messages to a file? (i.e. - protocolling/0 succeeds.)

You can’t. Quoted write escapes special characters in quoted atoms and strings. Probably print_term/2 is what you are looking for.

1 Like