I think Frank Meineke wrote:
> 
> Hello,
> 
> sorry, another newbie here - anyway,  I have two questions:
> 
> 1) (a easy one i hope)
> How do I retrieve a slot value from a fact?
> 
> e.g.:
> 
> ------------------------------------------------------
> (deftemplate aCar
>         (slot color)
> )
> 
> (deffunction printCar (?car)
> ; HERE IS THE PROBLEM
> ;       fact-slot-value exists in CLIPS, but not in JESS (?)
> ;       but it looks like a very basic functionality ?!
> ;       (printout t "This car is: " (fact-slot-value ?car color) crlf)
> )
> 
> (defrule listCars
>         ?car <- (aCar (color red))
>         =>
>         (printCar car)
> )

Here's a version that will work with the upcoming Jess 4.2 (later this
week). To make it work with Jess 4.1, you'll have to edit
jess/Rete.java and make the findFactByID function public.

----------------------------------------------------------------------
import jess.*;

/**
 * (C) 1998 Sandia National Laboratories and E.J. Friedman-Hill
 */

public class FactSlotValue implements Userfunction 
{    
  public String name() { return "fact-slot-value"; }
  public Value call(ValueVector vv, Context context) throws ReteException
  {
    Fact f = new Fact(context.engine().findFactByID(vv.get(1).factIDValue()),
                      context.engine());
    return f.findValue(vv.get(2).stringValue());
  }
}
----------------------------------------------------------------------


> ------------------------------------------------------
> 
> 2) (a harder one)
> - As i understood JESS Objects / Templates do not support inheritance, 
> such as 
> 
> (deftemplate aVehicle)
>         (slot numberOfWheels)
> )
> 
> What is the appropriate way now to mimick inheritance, such as
> (deftemplate aCar)              ; is aVehicle
> 
>         (slot isAVehicle) ; this won't work, but I would have liked it
>         (slot hasHorsePower)
> )
> 
> (detemplate aBicycle)   ; is aVehicle
>         ...
> )
> 
> - can slot values be templates again?
> - or should one use multislots preferably to templates 
> - or should one use only ordered facts, where each level of inheritance 
>   adds new items?
> 

None of the above. You should wait for Jess 5.0 (a first alpha version will
be released within a week), which support inheritance of deftemplates,
defclasses, deftemplates from defclasses, and defclasses from deftemplates.

> 
> Thank you,
> 
> Frank Meineke
> 
> __________________________________________________________________________
> Dipl.Inform. Frank Meineke                    [EMAIL PROTECTED] 
> Institut fuer Medizinische Informatik, Statistik und Epidemiologie (IMISE)
> Tel:+49-(0)341-9716111   Fax:9716109   URL:www.imise.uni-leipzig.de/~frank
> ---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------

Reply via email to