|
From: Oliver W. <Ath...@gm...> - 2002-03-11 16:51:53
|
Hi,
>
> > 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.
The Command is working fine, that is right.
>
> > 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.
It looks like I can not use the standard descriptors to communicate, so I'm
glad for
your advice.
>
> 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?
Thanks, it does answers some of the Questions I had,
I tried it already, and I do not understand how to send to the created Pipe.
I tried it with write/2 but I have no Idea how to handle the IO-Stream,
I tried so far ...
:- exec('java Frame',[pipe(Stream),pipe(Answer),null],_).
:- write(Stream, "message").
[ INSTANTIATION ERROR- write/2 in prolog:write/2: expected bound value ]
or
:- exec('java Frame',[pipe(Stream),pipe(Answer),null],_).
:- write(pipe(Stream), "message").
[ DOMAIN ERROR- write/2 in prolog:write/2: pipe(_537) not a stream ]
or
:- exec('java Frame',[pipe(stream),pipe(answer),null],_).
:- write(stream, "message").
:- user:exec(java Frame,[pipe(stream),pipe(answer),null],_552) failed.
[ EXISTENCE ERROR- write/2 in prolog:write/2: stream not an open stream ]
or
:- exec('java Frame',[pipe(stream),pipe(nswer),null],_).
:- write(pipe(stream), "message").
:- user:exec(java StoryFrame,[pipe(stream),pipe(answer),null],_552) failed.
[ DOMAIN ERROR- write/2 in prolog:write/2: pipe(_537) not a stream ]
It did not work ... the docs did not help.
Thanks so far
Oliver
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net |