Hi,

Well, I'm not 100% sure what you're trying to do. 'paolo' is an
instance of jess.Value or a subclass thereof, so
the println will print "jess.Value", "jess.Variable", or
"jess.FuncallValue", and you're probably not expecting that.

Note, by the way, that you evaluate the paolo object twice, once when
you call externalAddressValue and once when you call stringValue();
this might be bad if paolo is a FuncallValue, since then you'll
execute this function twice. To avoid this, make the first line read

  Value paolo = vv.get(1).resolveValue(context);

(See Jess manual section 4.2.2.)

I'm also not sure what you want the stringValue() call to do. It looks
like you believe paolo should contain an AttuazioneBean object as an
EXTERNAL_ADDRESS. It cannot also contain a String! Maybe you expect
toString() to be called automatically? It will not be.

Because the function is called fact-out-2, and because it's returning
a String, perhaps you want a String rendering of the shadow fact that
represents this object? Jess doesn't provide any easy way to get such
a thing, at least, not that I can think of right now. Roughly, you
could do something like

String getStringFormOfShadowFact(Object o)
{
 for (Enumeration e = rete.listFacts(); e.hasMoreElements();)
 {
  Fact f = (Fact) e.nextElement();
  if (f.isShadow() && f.getSlotValue("OBJECT") == o)
    return f.toStringWithParens();        
 }                           
 // Not found, throw an exception or something.
}





I think Alessandro Saporiti wrote:
> Hi,
> I have write the following java code , but this function don't work! 
> I'm missing somethings?
> 
> import jess.*;
> 
>  public class FactOut2 implements Userfunction
>     {
>       public String getName() { return "fact-out-2"; }
>       public Value call(ValueVector vv, Context context) throws JessException
>         {
>             Value paolo =  vv.get(1);
>             AttuazioneBean AttuazioneObject = (AttuazioneBean)
> paolo.externalAddressValue(context);
>             System.out.println("Bean object :" + paolo.getClass().getName()  );
>             return new Value (vv.get(1).stringValue(context), RU.STRING);
> 
>         }
>     }
> 
> Thank in advance.
> Alessandro 
> ---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------

Reply via email to