On Fri, Nov 21, 2008 at 10:34 AM, John Chrysakis <[EMAIL PROTECTED]>wrote:

>
> > > If i need to setState for all Doors how can I do that??
> > >
> >
> > Just write a rule that matches all doors and set the state to closed.
> > (defrule allClosed
> >   (Door (OBJECT ?door))
> > =>
> >   (?door setState "closed")
> > )
> >
> > Or use a def query...
> >
>
>
> Excuse me,but does the above rule mean that each instance of door
> will be set to closed???


Well, yes, you were asking for a way to setState for *all* Door things.


>
> So, If I would like to set the state in a specific door named Door1 then
> is it correct the following rule?
>
>  (defrule allClosed
>   (Door (OBJECT ?door) (door == "Door1) )
>  =>
>    (?door setState "closed") )
>

Basically this is correct, except for the syntax - if you use this form
for testing a slot value, you must use braces: { door == "Door1" }.

Also, make sure that the update (which happens due to a call
of the Java object's method) is announced to the Jess engine.
Please make sure to read chapter 5.3 on Shadow facts.

Notice that you might just as well update the object by updating
the fact:

(defrule closeDoor2
  ?d <- (Door { door == "Door2" }
=>
  (modify ?d (state "closed"))
)



> thanks a lot for your replies so far!
>
>
> --------------------------------------------------------------------
> 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