|
From: Vitor S. C. <vi...@bi...> - 2002-03-11 15:35:44
|
Hi Oliver,
> I'm trying to connect a Java Program to my Yap Code (Version 4.3.20).
> I start the Java through Yap with the "exec(Command,IO-List,Status)"
> Command.
>
I have been using that command myself and it seems to be working.
> I have Problems to build up a communication between those Parts, and tried
> to do it
> using the IO-List Parameters in exec/3 . I failed so far.
>
> Yap-Side:
>
> :- exec('java Frame',[user_input,user_output,user_error],Status).
>
> :- write(MSG_O).
>
> :- read(MSG_I).
>
> Java-Side:
>
> BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
> String tempString = "";
>
> while (tempString.compareTo("eof")!= 0) {
> tempString = in.readLine();
> log.println(tempString); // writes received MSG into a Log-File
> System.out.println("pos.");
> }
>
I don't understand very well what you are trying to do. You seem to be
wanting to share the standard descriptors, and I don't know if you can
use them to communicate.
In my program what I do to communicate with a matlab process is:
exec('matlab -nojvm -nosplash',[pipe(CommandStream),pipe(Answer),pipe(Answer)],_),
I send commands to the matlab shell using this procedure:
send_command(OStream, IStream, String, Args) :-
format(OStream, String, Args),
wait_for_matlab_prompt(IStream).
wait_for_matlab_prompt/1 just scans matlab until finding a matlab
prompt, which will be of the form >> or EDU>:
wait_for_matlab_prompt(Answer) :-
fetch_prompt(Answer, -1).
fetch_prompt(Answer, C0) :-
get0(Answer, C1),
( ((C0 = 0'> ; C0 = 0'U ) ,C1 = 0'> ) ->
true
;
fetch_prompt(Answer, C1)
).
It works fine for me (well, matlab is very slow ;-).
> Any Help or new Suggestions are Welcome.
> Thanks in advance for your Time and Help.
>
Does this help?
Cheers,
Vitor
|