standard input/output of a class instance

G

guesswho

Hi,

I was wondering if its possible to redirect input and output of a
JClips class .
I hava a java application with instance of JClips class (it makes
possible to fire CLIPS expert system in java), a clips file with code
of expert system where for example a kind of "c printf function"
prints sth on stdout and like "c scanf function" reads from stdin. Is
it possible to force my JClips instance to read for example from my
edit box
in other words how to redirect standard output/input of a class
instance

thanks for any help
 
T

Thomas Fritsch

guesswho said:
I was wondering if its possible to redirect input and output of a
JClips class .
It is possible to redirect input and output for the *process* as a
whole. But I don't know what you mean with "redirect input and output of
a *class* ".
I hava a java application with instance of JClips class (it makes
possible to fire CLIPS expert system in java), a clips file with code
of expert system where for example a kind of "c printf function"
prints sth on stdout and like "c scanf function" reads from stdin. Is
it possible to force my JClips instance to read for example from my
edit box
in other words how to redirect standard output/input of a class
instance
You can redirect standard output/input/error by
System.setIn(...);
System.setOut(...);
System.setErr(...);
See also the API doc of the java.lang.System.
 
C

Chris Uppal

guesswho said:
I was wondering if its possible to redirect input and output of a
JClips class .

I doubt if this is possible through the existing JClips API. CLIPS itself has
an elaborate framework ("IO Routers") to allow containing applications to take
control of the messages, etc, that CLIPS is producing. From a quick glance
through JClips I see no way to hook into that framework.

So I think the options are: give up, or extend JClips (not necessarily too
dificult if you are comfortable working in C).

-- chris
 
G

guesswho

Chris Uppal napisal(a):
I doubt if this is possible through the existing JClips API. CLIPS itself has
an elaborate framework ("IO Routers") to allow containing applications to take
control of the messages, etc, that CLIPS is producing. From a quick glance
through JClips I see no way to hook into that framework.

So I think the options are: give up, or extend JClips (not necessarily too
dificult if you are comfortable working in C).

-- chris

.... or maybe send sth to stdin from java application. Clips asks a
question in stdout (and sends string containing question to java app -
in JClips send-to-java func.) and is waiting for an answer from stdin
(keyboard) , so maybe write the answer to stdin from java app. Does it
makes sense ?
 
C

Chris Uppal

guesswho said:
Clips asks a
question in stdout (and sends string containing question to java app -
in JClips send-to-java func.) and is waiting for an answer from stdin
(keyboard) , so maybe write the answer to stdin from java app. Does it
makes sense ?

I don't see how to make that work myself, although I could be missing something
(I haven't looked into CLIPS much yet).

I don't think it's possible to do from outside CLIPS -- you just don't have
access from Java to the stdin and stdout streams that its C library is using.

You could probably do it by running CLIPS as an external process, which /would/
allow you to take control of its stdin/stdout -- but then you wouldn't be able
to use JClips.

-- chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,147
Latest member
CarenSchni
Top