Thank you for your answer,, but I found funny things.

 First I tried,

    (defrule find-os
       ?ask-stmt <- (ask-os ?hostname)
       (has-os ?hostname ?osname)
     =>
       (retract ?ask-stmt)
       (store OSNAME ?osname)
    (assert (has-os myhost unix))

   Rete rete = ...
   rete.executeCommand("(assert (ask-os myhost))");
   rete.run();
   System.out.println("OS is "+rete.fetch("OSNAME").stringValue());

   The result is NullPointerException.
   The return value of rete.fetch("OSNAME") is null

   Next I modifed find-os rule, 
     inserting (printout t ?hostname......)

    (defrule find-os
       ?ask-stmt <- (ask-os ?hostname)
       (has-os ?hostname ?osname)
     =>
       (retract ?ask-stmt)
       (printout t ?hostname" has "?osname crlf)
       (store OSNAME ?osname)

   The result is "OS is osname", not what I expected "OS is unix"
   The problem is that the variable ?osname is not dereferenced.

  Could you let me know where I did make mistakes?
  I'm using "jess50a2".

  Thanks in advance.

On Wed, 13 Jan 1999, Ernest Friedman-Hill wrote:

> There are many ways. One easy one is to use the 'store' and 'fetch'
> functions.
> 
>     (defrule find-os
>        ?ask-stmt <- (ask-os ?hostname)
>        (has-os ?hostname ?osname)
>      =>
>        (retract ?ask-stmt)
>        (store OSNAME ?osname)
>     (assert (host-os myhost unix))
> 
> 
>    Rete rete = ...
>    rete.executeCommand("(assert (ask-os myhost))");
>    rete.run();
>    String osname = rete.fetch("OSNAME").stringValue();
> 
> See the README for details.
> 
> I think Kyung Koo Jun wrote:
> > 
> > 
> >   Hi, all,
> > 
> >   In my case, test.clp is
> > 
> >    (defrule find-os
> >       ?ask-stmt <- (ask-os ?hostname)
> >       (has-os ?hostname ?osname)
> >     =>
> >       (retract ?ask-stmt)
> >       (printout t ?osname crlf))
> >    (assert (host-os myhost unix))
> > 
> >   in Java application
> > 
> >   Rete rete = ...
> >   rete.executeCommand("(assert (ask-os myhost))");
> >   rete.run();
> > 
> >   then Jess will print the result "unix" into
> >   standard output.
> >   However I'd like to make the Java application get 
> >   the result.
> > 
> >   Which way is the smartest one?
> >   Thanks in advance for the answers to the studpid question.
> > 
> >   
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> > in the BODY of a message to [EMAIL PROTECTED], NOT to the
> > list. List problems? Notify [EMAIL PROTECTED]
> > ---------------------------------------------------------------------
> > 
> > 
> 
> 
> ---------------------------------------------------------
> Ernest Friedman-Hill  
> Distributed Systems Research        Phone: (925) 294-2154
> Sandia National Labs                FAX:   (925) 294-2234
> Org. 8920, MS 9214                  [EMAIL PROTECTED]
> PO Box 969                  http://herzberg.ca.sandia.gov
> Livermore, CA 94550
> 
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> 

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to