The idea behind what you're doing is correct, but the implementation
is wrong if you're using Jess 6.x. In Jess 5.x, ?f would be bound to
an integer, the fact-id, and you need to call findFactByID to find the
actual fact object. In Jess 6.x, ?f is bound to the actual jess.Fact
object, so the lookup call is unnecessary and incorrect.

Given the Fact, then, calling toStringWithParens should then do what
you want.


I think Jack Kerkhof wrote:
> Hi all,
> 
> Does anyone know how to get the string version of a fact from a fact ID?
> (i.e. that can be used with assert-string)
> 
> I don't see a function to do this in the function list.
> 
> I tried the following but it doesn't work:
> 
> 
> (deftemplate test-fact (slot one) (slot two) )
> 
> (assert-string "(test-fact (one cat) (two dog))")
> 
> (defrule test-assert-string
>      ?f<-(test-fact (one ?x) (two ?y))
> =>
> 
>      ; get fact from fact ID. WHY DOES THIS FAIL?
>      ;    I assume (engine) returns the current Rete INSTANCE (doc is
> not clear on this)
>      ;    It complains: Message: No overloading of method 'findFactByID'
> ?
>      (bind ?fct (call (engine) findFactByID ?f)) ;
> 
>      ; get string version of fact (is there a better way???)
>      (bind ?s   (call ?fct toStringWithParens ))
>      (printout t " string fact = " ?s crlf)
> 
>      ; do something really meaningless to test
>      (retract ?f)
>      (assert-string ?s)
> 
> )
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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