From nangelop@csd.abdn.ac.uk  Thu Aug 24 12:42:12 2000
Received: from pigeon.csd.abdn.ac.uk (root@pigeon.csd.abdn.ac.uk [139.133.200.15])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id MAA04392
	for <prolog@swi.psy.uva.nl>; Thu, 24 Aug 2000 12:42:12 +0200 (MET DST)
Received: from kea (nangelop@kea [139.133.200.24])
	by pigeon.csd.abdn.ac.uk (8.11.0/8.11.0) with ESMTP id e7OAgAj08679;
	Thu, 24 Aug 2000 11:42:10 +0100 (BST)
Date: Thu, 24 Aug 2000 11:42:09 +0100
From: Nicos Angelopoulos <nangelop@csd.abdn.ac.uk>
To: Manny Obrey <manny8383@hotmail.com>
cc: prolog@swi.psy.uva.nl
Subject: Re: input/output redirect
In-Reply-To: <LAW-F232gkzpB8JPGbF00000c34@hotmail.com>
Message-ID: <Pine.SGI.4.21.0008241055490.99482-100000@kea.csd.abdn.ac.uk>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII



On Wed, 23 Aug 2000, Manny Obrey wrote:

> 
>   hello,
> 
>       i'd like to do the following
> 
>       >prolog -c database < inputfile > outputfile
> 
>       where 'database' is a file w/ clauses,
>       'inputfile' contains queries, and
>       'outputfile' contains the output from the queries.
>       All i end up w/ however is an empty 'outputfile'.
> 
>       any hlp for a newbie app.
>       - manny
> 

1. you should change -c to -f, alternatively, use -g consult(database).

eg

% pl -f database < inputfile > outputfile
 
% pl -g 'consult(database)' < inputfile > outputfile

2. an alternative way would be to change your inputfile to
something like

:- consult( database ).

main( OutFile ) :-
	tell( OutFile ),
	q1( _X ),
	q2( _Y ),
	...
	qn( _Z ),
	told.


% pl -g 'consult(inputfile),main(outputfile),halt'


in any case you need to make sure queries in 1. succeed only once

for a more declarative style you mind want to consider 
things like 

main( OutFile ) :-
	findall( X, q1(datum1,X), Xs ),
	once( q2(datum2,Y) ),
	tell( OutFile ),
	write( 'q1(datum1,X) - Xs :' ), write( Xs ), nl,
	write( 'once(q2(datum1,Y)) - Y :' ), write( Y ), nl,
	write( 'call(q3(datum3)) :' ), nl,
	q3(datum3), 
	told.



nicos.

