[EMAIL PROTECTED] wrote:
>
> There are many ways you could do this; one simple way is to use the
> fetch and store functions. There's an example in section 4.4.4 of the
> manual.
I looked at these but they don't show them used in the manner I am
trying to use them and I'm not sure the proper way to acomplish it.
Here is an example:
I have a fact called "fuel" which has a single parameter: of
java.lang.Integer which defines the amount of fuel available.
I want to have a rule that determines if the fuel is low. I know the
fuel can only be decrimented by one at a time.
the rule I want is:
(defrule fuelLow (fuel java.lang.Integer(4))
=>
(assert (lowFuelLevel)))
obviously I can't just do it like that so I have tried a couple of
different things, neither of them work.
I have stored the java.lang.Integer on the java side using
Rete.store("x1", new java.lang.Integer(4)). Then I create the string
that looks like:
(defrule fuelLow (fuel (fetch x1)) => ...
using Rete.executeCommand() this gave me a parse error.
I then tried the same store but tried to use bind to get what I needed.
I sent in "(bind ?X1 (fetch x1))" in executeCommand() and used the
following for my rule:
(defrule fuelLow (fuel ?X1) => ...
This would allow ?X1 to be bound to any external address though (treated
as if unbound - which does make sense in a rule).
I am a bit at a loss here. It is possible I just can't do what I want
to do.
I realise that I could just use a primitive JESS type rather than
java.lang.Integer but this is just a simple example. I need to be able
to do this for a general case with many different user defined classes.
I also have a large set of facts and the rules can be defined
dynamically so I need to be able to generate it rather than hard code
anything.
Anyway, I am a major newbie to JESS (though I used CLIPS long ago) and
I just can't figure out how to do this.
Kevin Kelly
--------------------------------------------------------------------
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]
--------------------------------------------------------------------