Re: Bug with streams or listing?
Lindsey Spratt <[email protected]>
| Newsgroups | gmane.comp.gnu.prolog.bugs |
|---|---|
| Message-ID | <[email protected]> |
The problem here is that listing/1 does not write to stdout (which is
what tell/1 redirects) but rather to top_level_output. I don't know if
there's any way to redirect top_level_output. (I would think listing/1
*should* use stdout.)
You can write listing/1 to an arbitrary stream using a *mirror*:
?- open('foo', write, S), add_stream_mirror(top_level_output, S),
listing(kb), close(S).
This will write the listing for kb to file 'foo'.
Lindsey Spratt
On Nov 6, 2005, at 10:46 AM, Daniel Savard wrote:
> Seems there is a bug with the streams implementation. I am newbie to
> both gnu-prolog and prolog, I am trying to save a knowledge base using
> the following fragment of code. This code is working properly with
> swi-prolog-lite, but not with gnu-prolog. Only the write statement
> produce some output in the file, the listing predicate is generating
> output to the screen as if the user_output stream has not been
> redirected into the file bozo.pl. A write after listing will output to
> the file as expected. What is going wrong with listing? Is there a
> work around?
>
> consult('toto.pl').
> open('bozo.pl',write,Fic),set_output(Fic),write(':-
> dynamic(kb/2).'),nl,listing(kb),flush_output(Fic),close(Fic).
>
> Assume the output file is bozo.pl and the knowledge base is kb and in
> file toto.pl.
>
> I tried as well this way with the same result, working fine with
> swi-prolog-lite:
>
> consult('toto.pl').
> tell('bozo.pl'),write(':- dynamic(kb/2).'),nl,listing(kb),told.
>
> I am running gnu-prolog 1.2.16 with Linux kernel 2.6.13.
>
> TIA,
>
> --
> -----------------
> Daniel Savard
>
>
> _______________________________________________
> Bug-prolog mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/bug-prolog
>