Hi Glenn -
You're not binding the variable ?f anywhere in this rule; ?f is
therefore of type 8 (= RU.VARIABLE, an unassigned variable). Ordinary
variables are limited to the scope in which they're used; i.e., you
can't bind something to an ordinary variable in one rule and read it
in another. You could use a defglobal for this purpose (?*tf* in the
example below), -or- you could explicitly bind a local to the value
you're interested in on this rule's LHS (i.e., given my example below,
including the pattern
(holder (field ?f))
on the rule's left-hand-side would make your testExtern rule work.)
I think Glenn Williams wrote:
>
> When I try to use the slot value as follows:
>
> ( defrule testExtern
> ( dependency ( externalObserver ?eo ) )
> =>
> ( printout t ?eo crlf )
> (set ?f background ( get-member java.awt.Color red ))
> )
>
> I get the following exception:
>
> Rete Exception in routine Value::externalAddressValue while executing
> defrule testExtern while executing deffunction quitButton-handler.
> Message: Not an external address: ?f type = 8
>
> Any clues?
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> > Behalf Of Ernest Friedman-Hill
> > Sent: Wednesday, August 26, 1998 4:09 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: JESS: Referencing externals
> >
> >
> > Hi Glenn,
> >
> > I've been having a bit of trouble following this thread; the
> > terminology is a bit non-standard. How about I show a working example
> > of something, and you tell me why it's not what you want:
> >
> > ;----------------------------------------------------------------------
> > Jess, the Java Expert System Shell
> > Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
> > Jess Version 4.1b6 8/20/98
> >
> > Jess> (set-reset-globals FALSE)
> > FALSE
> > Jess> (defglobal ?*tf* = (new java.awt.TextField))
> > TRUE
> > Jess> (deftemplate holder (slot field))
> > TRUE
> > Jess> (deffacts my-facts (holder (field ?*tf*)))
> > TRUE
> > Jess> (defrule test-rule
> > (holder (field ?f))
> > =>
> > (printout t ?f crlf))
> > TRUE
> > Jess> (reset)
> > TRUE
> > Jess> (run)
> > <External-Address:java.awt.TextField>
> > TRUE
> > Jess>
> > ;----------------------------------------------------------------------
> >
> >
> > I think Glenn Williams wrote:
> > >
> > > Thanks for the reply.
> > >
> > > > Obviously, the "?e <- (editor (field ?tf))" will only work on the
> > > > LHS of a rule, allowing you to access the TextField object on the
> > > > RHS via the bound value ?tf. To access externals outside of a rule,
> > >
> > > The problem is when I try to bind the value of the external to ?tf, the
> > > pattern never match's. The following never match's, even though
> > there are
> > > facts which it should fire on. externalObserver is bound to an external
> > > java.awt.TextField.
> > >
> > > ( dependency ( subject ?addressID ) ( externalObserver ?observer ) )
> > >
> > > I want to put external global's in facts, retrieve them, and use them.
> > >
> > > glenn
> > >
> >
> > > > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On
> > > > Behalf Of Al Davis
> > > >
> > > > Glenn,
> > > >
> > > > Obviously, the "?e <- (editor (field ?tf))" will only work on the
> > > > LHS of a rule, allowing you to access the TextField object on the
> > > > RHS via the bound value ?tf. To access externals outside of a rule,
> > > > try using the store/fetch methods or directly use your global.
> > > >
> > > >
> > > > On Wed, 26 Aug 1998, Glenn Williams wrote:
> > > >
> > > > > I'd like to do the following:
> > > > > ( deftemplate editor ( slot field ) )
> > > > > ( defglobal ?*t* = new java.awt.textField )
> > > > >
> > > > > ( assert editor ( field ?*t* ) )
> > > > >
> > > > > This works, the reference is loaded into editor, but how do I
> > > > retrieve it?
> > > > >
> > > > > I tried:
> > > > >
> > > > > ?e <- ( editor ( field ?tf ) )
> > > > >
> > > > > which fails.
> > > > >
> > > > > How do I can I get and use the external reference?
> > > > >
> > > > > glenn
> > > > >
> > > > > >
> >
> >
> >
> > ---------------------------------------------------------
> > Ernest Friedman-Hill
> > Distributed Systems Research Phone: (510) 294-2154
> > Sandia National Labs FAX: (510) 294-2234
> > Org. 8920, MS 9214 [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. List problems? Notify [EMAIL PROTECTED]
> > ---------------------------------------------------------------------
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
>
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (510) 294-2154
Sandia National Labs FAX: (510) 294-2234
Org. 8920, MS 9214 [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. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------