I think Joe wrote:
> Omitting all the extras, I have facts that are
> asserted and retracted in this template:
> (recommend (prefix MAC) (number "2003"))
> 
> I want to be able to have some kind of array in my
> java program(where the gui is) that can know when
> these facts are asserted (and add them to the array)
> and retracted(and remove them from the array). What is
> the best way to do this? Also, I would like to make
> the array to be of objects called courses so that I
> can store the prefix and number in separate members. 
> 

Well, to answer the question you asked, you just need to write a class
that implements the JessListener interface, and register your listener
with your Rete object. You'll get events of type RU.FACT + RU.ADDED
when facts are asserted, and RU.FACT + RU.REMOVED when they're
retracted. The "data" associated with the event will be a jess.Fact
object. You can read about all of these things in the "Programming in
Jess with Java" chapter of the manual: See
http://herzberg.ca.sandia.gov/jess/docs/61/library.html .

Now, to tell you something you didn't ask about: this isn't really the
best way to do this. Rather than creating objects based on facts, it
would be easier and cleaner to create the objects and let Jess work
with them directly. Instead of asserting facts, you'd use the
definstance function to register objects with Jess, and undefinstance
to remove them. You could create Course objects in Jess using a
deffunction that called definstance and also called a function
provided by your GUI class to add the items to the list; similarly,
you could retract them using a deffunction that also removed them from
the GUI.



---------------------------------------------------------
Ernest Friedman-Hill  
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to