Thanx in advance for any ideas that you all might have!


I am trying to do something fairly simple but for some reason I can't figure
it out... I've got a mental block here and a fundamental misunderstanding I
think? And right now my brain is fried! :^)

First of all I am adding my own user function with the purpose of parsing
its parameters and creating an unordered fact which is simply composed of
atoms. Thus, for example, I would like to call this function, AssertFact
like this:
(AssertFact "Inferred INT_INF"  34)

and have it result in the following fact:
f-1 (Inferred INT_INF 34)

The fact that I'm getting instead is like this:
f-1 ( "Inferred INT_INF" 34)   // Notice the space after the open-paren as
well as the double quotes!


Here is my code to attempt this rather simple feat:
class AssertFact implements Userfunction
{
        int _name = RU.putAtom("AssertFact");
        public int name() { return _name; }

        public Value call(ValueVector vv, Context context) throws ReteException
        {
                Fact fact = new Fact ("", RU.ORDERED_FACT, context.engine ()); // There
must be a better way to create a new fact?

                for (int i = 1; i < vv.size(); i++)
                {
                        if (vv.get(i).type () == RU.STRING)
                        {
                                StringTokenizer stringTokenizer = new StringTokenizer 
(vv.get
(i).toString ());
                                while (stringTokenizer.hasMoreTokens ())
// Trying to de-volve this string into atoms!
                                        fact.addValue (new Value 
(stringTokenizer.nextToken (), RU.ATOM));

// This didn't work either!     fact.addValue (stringTokenizer.nextToken (),
RU.ATOM);
// Tried using a ValueVector directly like this but it didn't seem to work:
// myValueVector.add (new Value (stringTokenizer.nextToken (), RU.ATOM);
// Then at the end doing this: context.engine ().assert (myValueVector); //
No luck on that either!
                        }
                        else
                                fact.addValue (vv.get(i));
                }

                context.engine ().assert (fact.factData ());

                return Funcall.TRUE();
        }
}

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