JESS: Retrieving slot and multislot values

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

JESS: Retrieving slot and multislot values

Donald Winston
/* I need to retrieve slot and multislot values. */

Value v1 = fact.getSlotValue(slotName).toString());
/* Assuming above is ok */
Value v2 =  fact.getSlotValue(multiSlotName);
ValueVector vv = v2.listValue(context);

where or how do I construct an appropriate "context"?

Do I need to do this for v1 also or is toString() good enough?
Reply | Threaded
Open this post in threaded view
|

Re: JESS: Retrieving slot and multislot values

Friedman-Hill, Ernest
I don't know the context (sorry) in which you're doing this, so you'll  
have to make up your own mind. Read this for some info:

http://www.jessrules.com/jess/docs/71/library.html#resolution

You can always use the global context for a Rete object by calling  
Rete.getGlobalContext() . If you absolutely, positively know that a  
value contains no variables, and no function calls that produce a  
variable or reference a Rete object, then you can get away with  
passing "null" -- but getGlobalContext() is safer, of course.



On Sep 15, 2010, at 11:02 AM, Donald Winston wrote:

> /* I need to retrieve slot and multislot values. */
>
> Value v1 = fact.getSlotValue(slotName).toString());
> /* Assuming above is ok */
> Value v2 =  fact.getSlotValue(multiSlotName);
> ValueVector vv = v2.listValue(context);
>
> where or how do I construct an appropriate "context"?
>
> Do I need to do this for v1 also or is toString() good enough?

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [hidden email]'
in the BODY of a message to [hidden email], NOT to the list
(use your own address!) List problems? Notify [hidden email].
--------------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: JESS: Retrieving slot and multislot values

Donald Winston
In reply to this post by Donald Winston
engine.getGlobalContext() ??
I thought this was just for global variables.

On Sep 15, 2010, at 11:02 AM, Donald Winston wrote:

/* I need to retrieve slot and multislot values. */

Value v1 = fact.getSlotValue(slotName).toString());
/* Assuming above is ok */
Value v2 =  fact.getSlotValue(multiSlotName);
ValueVector vv = v2.listValue(context);

where or how do I construct an appropriate "context"?

Do I need to do this for v1 also or is toString() good enough?

Reply | Threaded
Open this post in threaded view
|

Re: JESS: Retrieving slot and multislot values

Wolfgang Laun-2

On 15 September 2010 17:17, Donald Winston <[hidden email]> wrote:
engine.getGlobalContext() ??
I thought this was just for global variables.

It's for defglobals and variables bound at the outermost level.

But Jess is subject to scoping, where an "inner" scope may introduce an name not know globally, or reuse a name from an outer scope by binding it to another value.

You won't need to use Contexts other than that getGlobalContext() unless you are into Event handling or sophisitcated exception handling.

-W