|
From: | A-S Saidi |
Subject: | Re: streams |
Date: | Mon, 05 Sep 2005 16:05:45 +0200 |
User-agent: | Mozilla Thunderbird 1.0.2 (X11/20050317) |
Hi, Gonna give youthe answer I got some time ago (the same question !). Things work by the solution (1) but more generaly by (2). Regards. Alexandre. ______________________________________________________________ 1- .... Here is what I did (essentially your example but in two steps): Best regards, Johannes $ gprolog GNU Prolog 1.2.18 By Daniel Diaz Copyright (C) 1999-2004 Daniel Diaz | ?- [user]. compiling user for byte code... entier(0). entier(succ(N)) :- entier(N). user compiled, 3 lines read - 348 bytes written, 8476 ms (1 ms) yes | ?- open(fichier,write,F), current_input(I), current_output(O), asserta(streams(F,I,O)), '$set_top_level_streams'(I, F),entier(succ(succ(0))). | ?- retract(streams(F,I,O)), '$set_top_level_streams'(I, O), close(F). F = '$stream'(2) I = '$stream'(0) O = '$stream'(1) (1 ms) yes | ?- halt. $ cat fichier F = '$stream'(2) I = '$stream'(0) O = '$stream'(1) yes $ ___________________________________________________________ 2- via script cpmmand : Following my question about "stdout redirection in Gprolog", Gurvan Le Guernic gave a general answer ("script" command under Unix/Linux) that did the job. I post it hereby. This works not only for Gprolog but also for any command. In order to gather (to mirror) outputs, launch " script -c gprolog myfile" and "myfile" is a mirrir of the stdout : (see "man script" also). Here's an example (sorry for Windoz users !): --------------------------------------------------------- address@hidden:> script -c gprolog toto Le script a débuté, le fichier est toto GNU Prolog 1.2.16 By Daniel Diaz Copyright (C) 1999-2002 Daniel Diaz | ?- write(1). 1 yes | ?- listing. yes ....................... | ?- halt. Script complélé, le fichier est toto address@hidden:> address@hidden:> cat toto Le script a débuté sur mar 01 mar 2005 19:58:00 CET GNU Prolog 1.2.16 By Daniel Diaz Copyright (C) 1999-2002 Daniel Diaz | ?- write(1). 1 yes | ?- listing. yes ..................... | ?- halt. Script complété sur mar 01 mar 2005 19:58:10 CET --------------------------------- Cliff Bender a écrit : Hi, -- Aleksander S. Saidi Ecole Centrale de Lyon Département Mathématiques-Informatique Mél : address@hidden Tél : 04.72.18.65.30, Fax : 04.78.33.16.15 |
Alexandre.Saidi.vcf
Description: Vcard
[Prev in Thread] | Current Thread | [Next in Thread] |