This is a followup to a message I sent to the userlist about a week ago asking
if anyone had been able to retrieve the text form of a jess fact as a string,
given its fact id.  

I am now able to get, as a java string, a fact.  I made the
jess.Rete.findFactByID method public, and was able to make a call like:
(call (new jess.Fact (call (engine) findFactByID 0) (engine)) toString)

findFactByID will return a ValueVector from of a fact given the integer fact
ID.  you can make it into a jess.Fact and then call the toString method.  fine
fine fine.

But now, the big question.  

How do I turn a variable that has been bound to a fact-ID into the
corresponding integer?

for example
(defrule foo ?x<-(foo ?)=>
        (printout t
                (call (new jess.Fact (call (engine) findFactByID ?x) (engine)) 
                toString)
        crlf)
)

this bombs out, because ?x is not an integer.  

In reading the README.html file, I noticed that the definition of what  a jess
variable is not all too clear.  Originally, in section 2.7, it is stated that
a variable can refer to "an atom, number or string", but later when referring
to pattern bindings (2.15.1) it is stated that the variable is bound to a fact-id.

In calls to retract, there seems to be an implicit conversion because the
documentation states that retract takes integers as arguments, but it also
works with variables bound to fact-IDs.  Additionally, calling (new
java.lang.Integer ?x) will fail if ?x is bound to a fact id.

anyway.  I am confused and lost in a sea of "but all I want to do is be able
to call (facttostring <factid>) and have it return a string..."

Thanks for all the help,
Eric Eslinger
---------------------------------------------------------------------
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