I am using pillow to develop an interface to some existing, complex, planning tools written in sicstus prolog as part of my final year project at university.
The planning tools output using write statements.
In order to run a test on the web I used the following code extract.
compute_reply('',_,'') :- !.
compute_reply(File,Test,Reply) :-
['planner.pl'],
Reply = [ --, 'The result is ', test1, '.',\].
I need to run a test, which basically requires me to call a function called test1
Of course if I do this before the Reply = [ ] then the test executes and as this is before the valid html output in the main it causes an error.
However if I try to call it in the reply statement for example
Reply = ['The results are ', test1, '.' ,\]. then it is taken as a string and the output is
'The results are test1'
So I was wondering if there was a way of running a test within the Reply initialisation.
Unfortunately Sicstus does not seem to be able to redirect the stream to a string as this would prbably have solved the problem.
I would prefer not to change the planner if at all possible.
Thankyou for any help you can provide.
______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
You can do (note that Reply is not passed out any more):
compute_reply(File,Test) :-
['planner.pl'],
output_html([ --, 'The result is ' ]), test1, output_html([ '.',\]).
i.e., write directly to user_output. Depending on what test1 prints you may need to do something more to get it to format nicely.
On Mon, 3 Apr 2000, katie tipps wrote:
............ things deleted
'The results are test1'
So I was wondering if there was a way of running a test within the Reply initialisation.
Unfortunately Sicstus does not seem to be able to redirect the stream to a string as this would prbably have solved the problem.
If i undertand correctly this seems more of a SICStus rather than pillow question,
in any case, my preferred way to do this (in that system) would be, to use SICStus' library, charsio | ?- use_module(library(charsio)). in particular the pred, with_output_to_chars/2 with_output_to_chars(+Goal, -Chars)
(the other approaches are left as an exercise for the reader)
and ... frankly you should try, if possible, to find a more structured alternative to your test1 (test1/0 i pressume) _structured_ as in ntest :- produce( List ), write_list( List ).
produce/1 is preferred to calling nt/0 with redirections and the like
I would prefer not to change the planner if at all possible.
you might think it is painful but it depends how careful the original programmers were, in most cases you should nt be required to CHANGE anything just find out which predicate to call
Thankyou for any help you can provide.
Get Your Private, Free Email at http://www.hotmail.com
nicos.