The argument to the Fact constructor should be the "head" of the fact
-- i.e., "animal-is". The second word, "duck", is the data in the
first slot. So you're creating a fact ("animal-is duck") when actually
you mean to create ("animal is" "duck"). The Fact constructor doesn't
check to see that its argument is a well-formed symbol -- that much is
up to you.
Section 4.7.3 of the manual shows how to construct an ordered fact in
Java; briefly, you want to do something like
Fact f = new Fact("animal-is", r);
ValueVector slotData = new ValueVector();
slotData.add(new Value("duck", RU.ATOM));
f.setSlotValue("__data", new Value(slotData, RU.LIST));
r.assertFact(f);
I think John Norris wrote:
> Hi,
>
> I'm new to Jess and CLIPS so I'm working my way through Giarratano's
> CLIPS user guide.
>
> I can do all his early examples in Java, ie assertFact, retract, reset,
> clear etc. I do have problems however with the duck / quack example :)
>
> // this seems to work OK
> r.assertFact (new Fact ("animal-is duck", r));
>
> // I then add the rule
> cmd = " (defrule duck (animal-is duck) " +
> " => (assert (sound-is quack)) )";
> System.out.println ( r.executeCommand (cmd));
>
> // but this then fails (ie returns 0)
> System.out.println ("r.run = " + r.run ());
>
>
> However, if I use executeCommand (assert...) then everything works OK:
>
> // start with this instead of assertFact and it works!
> cmd = " (assert (animal-is duck)) ";
> System.out.println ( r.executeCommand (cmd));
>
>
> Any ideas? Is there some default slot value not getting assigned?
>
> TIA,
>
> John
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) 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 9012 [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
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------