Well, the error is coming from this line:

   vecValue.add(new Value(factValue,RU.FACT));

This is invoking the Value constructor that takes a ValueVector and a
type, rather than the specific constructor that takes a Fact alone.
If you did use the right constructor, though, you'd still get an
error:

  Message: Cannot use jess.Value to represent fact-ids. You must use
  class jess.FactIDValue, 

as described in section 4.2.1 of the manual. In any case, the error
message you actually did see should recognize this mistake and explain
it; thanks for the report.

Now, all that aside, I must state in the strongest possible terms that
you *cannot* do this. You cannot, under any circumstances, make
modifications to Fact objects in working memory except by using the
modify function or the Rete.modify method. Doing so will corrupt
working memory and result in undefined behavior (see manual section
4.7). To use Rete.modify(), you could rewrite your helper as

       Value value=fact.getSlotValue(multislotName);
       ValueVector vecValue =value.listValue(engine.getGlobalContext());
       vecValue = (ValueVector) vecValue.clone();
       vecValue.add(new FactIDValue(factValue));
       engine.modify(fact, multislotName, vecValue);


I think portalguy wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> I'm calling a java function to insert a fact (created in jess script using
> assert) into a multislot, however I get the following message "Not a vector
> type: "nil" JessHelper: insertFactToMultislot"
> In the example below I'm basically adding an ancestor of type Human template
> to a multislot field.
> 
> Thanks in advance for the help.
> 
> 
> JessScript
> -----------
> (deftemplate Human
> (slot Name (type STRING))
> (multislot Ancestors))
> 
> (assert (Human (Name "a")
> (Ancestors (assert (Human (Name "b")))(assert (Human (Name "c"))))
> ))
> 
> (defrule addToMS
> "add to multislot"
> ?fact <- (Human (Name "a"))
> =>
> (call ?jessHelper insertFactToMultislot ?fact Ancestors (assert (Human (Name
> "d"))))
> )
> 
> java function
> --------------
>  public void insertFactToMultislot(Fact fact,String multislotName,Fact
> factValue)
>   {
>     try
>     {
>       Value value=fact.getSlotValue(multislotName);
>       ValueVector vecValue =value.listValue(engine.getGlobalContext());
>       vecValue.add(new Value(factValue,RU.FACT));
>     }
>     catch (JessException e)
>     {
>       System.out.println(e.getMessage() + " JessHelper:
> insertFactToMultislot");
>     }
>   }
> 
> 
> 
> 
> --------------------------------------------------------------------
> 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  
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