many thanks for the replay. Bobs list is working fine but i am also
interested in how defrule my-rule works. how can i use it?
(defrule my-rule
?fact <- (objects (o_id 90)))
=>
(modify ?fact (o_description NoKnife)))
regards,
M.ismail
From: "Ernest Friedman-Hill" <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: JESS: Modify in template
Date: Tue, 17 Jul 2007 12:34:47 -0400
To add one more option to Bob's list: as Jess is, after all, a rule- based
language, the intent is that most of the time you'll be doing this sort of
thing from a rule.
(defrule my-rule
?fact <- (objects (o_id 90)))
=>
(modify ?fact (o_description NoKnife)))
On Jul 17, 2007, at 11:14 AM, Robert Kirby wrote:
The modify function expects at least two parameters: the first is the fact
to be modified and the rest are slot name and modification value pairs.
If your Java code has the fact-id, then it could be inserted into the
string passed to executeCommand (which is deprecated in 7.0 for eval).
For instance, if the fact-id for o_id==90 were 20090, then
r.eval("(modify 20090 (o_description NoKnife))");
should work.
A Jess query could look up the fact within a function:
(defquery object-id-query
"Look up fact id."
(declare (variables ?id))
?fact <- (objects (o_id ?id)))
(deffunction modify-object-description
"Modify objects instance description"
(?id ?description)
(bind ?results (run-query* object-id-query ?id))
(?results next) ; Assumes exactly one objects instance with ?id
(modify (?results get fact) (o_description ?description))
(close ?results)
nil)
then run
r.eval("(modify-object-description 90 NoKnife)");
Bob Kirby
At 04:19 AM 7/17/2007, M Ismail wrote:
Hi,
i am using a template:
(deftemplate objects
(slot o_id)
(slot o_description)
(slot o_is_visible)
(slot o_makes_sound)
(slot o_sound_volume)
(slot o_framenumber)
)
and i want to modify the o_decription of the object with o_id = 90
how can i do that? if i use:
r.executeCommand("(modify (objects (o_id 90) (o_description NoKnife)))");
then i get errors and it doesnt work
best regards,
M. Ismail
_________________________________________________________________
Het meest spraakmakende nieuws vind je op www.msn.nl http:// www.msn.nl
--------------------------------------------------------------------
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 owner-jess- [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://www.jessrules.com
--------------------------------------------------------------------
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]
--------------------------------------------------------------------
_________________________________________________________________
Wil jij MSN reporter zijn? Deel jouw nieuws en verhalen hier!
http://reporter.msn.nl/
--------------------------------------------------------------------
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]
--------------------------------------------------------------------