Hi,
After few attempts in jess script i gave up and did it in java, below is the
whole class with the function. I would like to know if doing it in java
rather than jess script will be
any slower? I'm calling it from jess script.

package mypackage2;
import java.util.*;
import jess.*;
import jess.awt.*;
public class JessHelper
{
  Rete engine=null;
  public JessHelper(Rete engine)
  {
    this.engine=engine;
  }
  public Fact getFactByTemplateSlotValue(String strTemplate, String strSlot,
String strValue)
  {
     if(engine!=null)
     {
       Iterator facts = engine.listFacts();
       while(facts.hasNext())
       {
        Fact fact =(Fact)facts.next();
        Deftemplate template = fact.getDeftemplate();
        try
        {
          if((template.getBaseName().equals(strTemplate))&&(fact.getSlotValu
e(strSlot).toString().equals(strValue)))
          {
            return fact;
          }
        }
        catch (JessException e)
        {
          System.out.println(e.getMessage() + " JessHelper:
getFactByTemplateSlotValue");
        }
       }
     }
     return null;
  }
}

-----Original Message-----
From: portalguy [mailto:[EMAIL PROTECTED]
Sent: 18 January 2005 19:03
To: [email protected]
Subject: How to get a fact by the template, slot name and slot value on
RHS ?


sorry about the previous email, it was sent accidentally

Is there away on the RHS of the rule to guery the facts by the fact template
type,
slot name and slot value? my first attempt at it is to do something like
this

(defquery getFactByTemplateAndSlotAndValue
"Get fact by template, slot and Value"
(declare (variables ?T ?S ?V))
(?T (?S ?V)))

Thanks in advance for any help

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